id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
27,000
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function( url, data ) { data = data || {}; //if there's forward history, wipe it if ( this.getNext() ) { this.clearForward(); } // if the hash is included in the data make sure the shape // is consistent for comparison if ( data.hash && data.hash.indexOf( "#" ) === -1) { data.hash = "#" + data.hash; } data.url = url; this.stack.push( data ); this.activeIndex = this.stack.length - 1; }
javascript
function( url, data ) { data = data || {}; //if there's forward history, wipe it if ( this.getNext() ) { this.clearForward(); } // if the hash is included in the data make sure the shape // is consistent for comparison if ( data.hash && data.hash.indexOf( "#" ) === -1) { data.hash = "#" + data.hash; } data.url = url; this.stack.push( data ); this.activeIndex = this.stack.length - 1; }
[ "function", "(", "url", ",", "data", ")", "{", "data", "=", "data", "||", "{", "}", ";", "//if there's forward history, wipe it", "if", "(", "this", ".", "getNext", "(", ")", ")", "{", "this", ".", "clearForward", "(", ")", ";", "}", "// if the hash is included in the data make sure the shape", "// is consistent for comparison", "if", "(", "data", ".", "hash", "&&", "data", ".", "hash", ".", "indexOf", "(", "\"#\"", ")", "===", "-", "1", ")", "{", "data", ".", "hash", "=", "\"#\"", "+", "data", ".", "hash", ";", "}", "data", ".", "url", "=", "url", ";", "this", ".", "stack", ".", "push", "(", "data", ")", ";", "this", ".", "activeIndex", "=", "this", ".", "stack", ".", "length", "-", "1", ";", "}" ]
addNew is used whenever a new page is added
[ "addNew", "is", "used", "whenever", "a", "new", "page", "is", "added" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L10206-L10223
27,001
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function( historyEntry, direction ) { // make sure to create a new object to pass down as the navigate event data event.hashchangeState = $.extend({}, historyEntry); event.hashchangeState.direction = direction; }
javascript
function( historyEntry, direction ) { // make sure to create a new object to pass down as the navigate event data event.hashchangeState = $.extend({}, historyEntry); event.hashchangeState.direction = direction; }
[ "function", "(", "historyEntry", ",", "direction", ")", "{", "// make sure to create a new object to pass down as the navigate event data", "event", ".", "hashchangeState", "=", "$", ".", "extend", "(", "{", "}", ",", "historyEntry", ")", ";", "event", ".", "hashchangeState", ".", "direction", "=", "direction", ";", "}" ]
When the url is either forward or backward in history include the entry as data on the event object for merging as data in the navigate event
[ "When", "the", "url", "is", "either", "forward", "or", "backward", "in", "history", "include", "the", "entry", "as", "data", "on", "the", "event", "object", "for", "merging", "as", "data", "in", "the", "navigate", "event" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L10558-L10562
27,002
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function( href ) { // we should do nothing if the user wants to manage their url base // manually if ( !$.mobile.dynamicBaseEnabled ) { return; } // we should use the base tag if we can manipulate it dynamically if ( $.support.dynamicBaseTag ) { base.element.attr( "href", $.mobile.path.makeUrlAbsolute( href, $.mobile.path.documentBase ) ); } }
javascript
function( href ) { // we should do nothing if the user wants to manage their url base // manually if ( !$.mobile.dynamicBaseEnabled ) { return; } // we should use the base tag if we can manipulate it dynamically if ( $.support.dynamicBaseTag ) { base.element.attr( "href", $.mobile.path.makeUrlAbsolute( href, $.mobile.path.documentBase ) ); } }
[ "function", "(", "href", ")", "{", "// we should do nothing if the user wants to manage their url base", "// manually", "if", "(", "!", "$", ".", "mobile", ".", "dynamicBaseEnabled", ")", "{", "return", ";", "}", "// we should use the base tag if we can manipulate it dynamically", "if", "(", "$", ".", "support", ".", "dynamicBaseTag", ")", "{", "base", ".", "element", ".", "attr", "(", "\"href\"", ",", "$", ".", "mobile", ".", "path", ".", "makeUrlAbsolute", "(", "href", ",", "$", ".", "mobile", ".", "path", ".", "documentBase", ")", ")", ";", "}", "}" ]
set the generated BASE element's href to a new page's base path
[ "set", "the", "generated", "BASE", "element", "s", "href", "to", "a", "new", "page", "s", "base", "path" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L11727-L11740
27,003
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function() { var options = this.options, keepNative = $.trim( options.keepNative || "" ), globalValue = $.trim( $.mobile.keepNative ), optionValue = $.trim( options.keepNativeDefault ), // Check if $.mobile.keepNative has changed from the factory default newDefault = ( keepNativeFactoryDefault === globalValue ? "" : globalValue ), // If $.mobile.keepNative has not changed, use options.keepNativeDefault oldDefault = ( newDefault === "" ? optionValue : "" ); // Concatenate keepNative selectors from all sources where the value has // changed or, if nothing has changed, return the default return ( ( keepNative ? [ keepNative ] : [] ) .concat( newDefault ? [ newDefault ] : [] ) .concat( oldDefault ? [ oldDefault ] : [] ) .join( ", " ) ); }
javascript
function() { var options = this.options, keepNative = $.trim( options.keepNative || "" ), globalValue = $.trim( $.mobile.keepNative ), optionValue = $.trim( options.keepNativeDefault ), // Check if $.mobile.keepNative has changed from the factory default newDefault = ( keepNativeFactoryDefault === globalValue ? "" : globalValue ), // If $.mobile.keepNative has not changed, use options.keepNativeDefault oldDefault = ( newDefault === "" ? optionValue : "" ); // Concatenate keepNative selectors from all sources where the value has // changed or, if nothing has changed, return the default return ( ( keepNative ? [ keepNative ] : [] ) .concat( newDefault ? [ newDefault ] : [] ) .concat( oldDefault ? [ oldDefault ] : [] ) .join( ", " ) ); }
[ "function", "(", ")", "{", "var", "options", "=", "this", ".", "options", ",", "keepNative", "=", "$", ".", "trim", "(", "options", ".", "keepNative", "||", "\"\"", ")", ",", "globalValue", "=", "$", ".", "trim", "(", "$", ".", "mobile", ".", "keepNative", ")", ",", "optionValue", "=", "$", ".", "trim", "(", "options", ".", "keepNativeDefault", ")", ",", "// Check if $.mobile.keepNative has changed from the factory default", "newDefault", "=", "(", "keepNativeFactoryDefault", "===", "globalValue", "?", "\"\"", ":", "globalValue", ")", ",", "// If $.mobile.keepNative has not changed, use options.keepNativeDefault", "oldDefault", "=", "(", "newDefault", "===", "\"\"", "?", "optionValue", ":", "\"\"", ")", ";", "// Concatenate keepNative selectors from all sources where the value has", "// changed or, if nothing has changed, return the default", "return", "(", "(", "keepNative", "?", "[", "keepNative", "]", ":", "[", "]", ")", ".", "concat", "(", "newDefault", "?", "[", "newDefault", "]", ":", "[", "]", ")", ".", "concat", "(", "oldDefault", "?", "[", "oldDefault", "]", ":", "[", "]", ")", ".", "join", "(", "\", \"", ")", ")", ";", "}" ]
Deprecated in 1.4 remove in 1.5
[ "Deprecated", "in", "1", ".", "4", "remove", "in", "1", ".", "5" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L11922-L11941
27,004
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function() { var hist = $.mobile.navigate.history; if ( this._isCloseable ) { this._isCloseable = false; // If the hash listening is enabled and there is at least one preceding history // entry it's ok to go back. Initial pages with the dialog hash state are an example // where the stack check is necessary if ( $.mobile.hashListeningEnabled && hist.activeIndex > 0 ) { $.mobile.back(); } else { $.mobile.pageContainer.pagecontainer( "back" ); } } }
javascript
function() { var hist = $.mobile.navigate.history; if ( this._isCloseable ) { this._isCloseable = false; // If the hash listening is enabled and there is at least one preceding history // entry it's ok to go back. Initial pages with the dialog hash state are an example // where the stack check is necessary if ( $.mobile.hashListeningEnabled && hist.activeIndex > 0 ) { $.mobile.back(); } else { $.mobile.pageContainer.pagecontainer( "back" ); } } }
[ "function", "(", ")", "{", "var", "hist", "=", "$", ".", "mobile", ".", "navigate", ".", "history", ";", "if", "(", "this", ".", "_isCloseable", ")", "{", "this", ".", "_isCloseable", "=", "false", ";", "// If the hash listening is enabled and there is at least one preceding history", "// entry it's ok to go back. Initial pages with the dialog hash state are an example", "// where the stack check is necessary", "if", "(", "$", ".", "mobile", ".", "hashListeningEnabled", "&&", "hist", ".", "activeIndex", ">", "0", ")", "{", "$", ".", "mobile", ".", "back", "(", ")", ";", "}", "else", "{", "$", ".", "mobile", ".", "pageContainer", ".", "pagecontainer", "(", "\"back\"", ")", ";", "}", "}", "}" ]
Close method goes back in history
[ "Close", "method", "goes", "back", "in", "history" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L14193-L14207
27,005
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function( options ) { var key, accordion = this._ui.accordion, accordionWidget = this._ui.accordionWidget; // Copy options options = $.extend( {}, options ); if ( accordion.length && !accordionWidget ) { this._ui.accordionWidget = accordionWidget = accordion.data( "mobile-collapsibleset" ); } for ( key in options ) { // Retrieve the option value first from the options object passed in and, if // null, from the parent accordion or, if that's null too, or if there's no // parent accordion, then from the defaults. options[ key ] = ( options[ key ] != null ) ? options[ key ] : ( accordionWidget ) ? accordionWidget.options[ key ] : accordion.length ? $.mobile.getAttribute( accordion[ 0 ], key.replace( rInitialLetter, "-$1" ).toLowerCase() ): null; if ( null == options[ key ] ) { options[ key ] = $.mobile.collapsible.defaults[ key ]; } } return options; }
javascript
function( options ) { var key, accordion = this._ui.accordion, accordionWidget = this._ui.accordionWidget; // Copy options options = $.extend( {}, options ); if ( accordion.length && !accordionWidget ) { this._ui.accordionWidget = accordionWidget = accordion.data( "mobile-collapsibleset" ); } for ( key in options ) { // Retrieve the option value first from the options object passed in and, if // null, from the parent accordion or, if that's null too, or if there's no // parent accordion, then from the defaults. options[ key ] = ( options[ key ] != null ) ? options[ key ] : ( accordionWidget ) ? accordionWidget.options[ key ] : accordion.length ? $.mobile.getAttribute( accordion[ 0 ], key.replace( rInitialLetter, "-$1" ).toLowerCase() ): null; if ( null == options[ key ] ) { options[ key ] = $.mobile.collapsible.defaults[ key ]; } } return options; }
[ "function", "(", "options", ")", "{", "var", "key", ",", "accordion", "=", "this", ".", "_ui", ".", "accordion", ",", "accordionWidget", "=", "this", ".", "_ui", ".", "accordionWidget", ";", "// Copy options", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "options", ")", ";", "if", "(", "accordion", ".", "length", "&&", "!", "accordionWidget", ")", "{", "this", ".", "_ui", ".", "accordionWidget", "=", "accordionWidget", "=", "accordion", ".", "data", "(", "\"mobile-collapsibleset\"", ")", ";", "}", "for", "(", "key", "in", "options", ")", "{", "// Retrieve the option value first from the options object passed in and, if", "// null, from the parent accordion or, if that's null too, or if there's no", "// parent accordion, then from the defaults.", "options", "[", "key", "]", "=", "(", "options", "[", "key", "]", "!=", "null", ")", "?", "options", "[", "key", "]", ":", "(", "accordionWidget", ")", "?", "accordionWidget", ".", "options", "[", "key", "]", ":", "accordion", ".", "length", "?", "$", ".", "mobile", ".", "getAttribute", "(", "accordion", "[", "0", "]", ",", "key", ".", "replace", "(", "rInitialLetter", ",", "\"-$1\"", ")", ".", "toLowerCase", "(", ")", ")", ":", "null", ";", "if", "(", "null", "==", "options", "[", "key", "]", ")", "{", "options", "[", "key", "]", "=", "$", ".", "mobile", ".", "collapsible", ".", "defaults", "[", "key", "]", ";", "}", "}", "return", "options", ";", "}" ]
Adjust the keys inside options for inherited values
[ "Adjust", "the", "keys", "inside", "options", "for", "inherited", "values" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L14275-L14306
27,006
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function() { var dstOffset = this.handle.offset(); this._popup.offset( { left: dstOffset.left + ( this.handle.width() - this._popup.width() ) / 2, top: dstOffset.top - this._popup.outerHeight() - 5 }); }
javascript
function() { var dstOffset = this.handle.offset(); this._popup.offset( { left: dstOffset.left + ( this.handle.width() - this._popup.width() ) / 2, top: dstOffset.top - this._popup.outerHeight() - 5 }); }
[ "function", "(", ")", "{", "var", "dstOffset", "=", "this", ".", "handle", ".", "offset", "(", ")", ";", "this", ".", "_popup", ".", "offset", "(", "{", "left", ":", "dstOffset", ".", "left", "+", "(", "this", ".", "handle", ".", "width", "(", ")", "-", "this", ".", "_popup", ".", "width", "(", ")", ")", "/", "2", ",", "top", ":", "dstOffset", ".", "top", "-", "this", ".", "_popup", ".", "outerHeight", "(", ")", "-", "5", "}", ")", ";", "}" ]
position the popup centered 5px above the handle
[ "position", "the", "popup", "centered", "5px", "above", "the", "handle" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L16497-L16504
27,007
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function() { var screen = this._ui.screen, popupHeight = this._ui.container.outerHeight( true ), screenHeight = screen.removeAttr( "style" ).height(), // Subtracting 1 here is necessary for an obscure Andrdoid 4.0 bug where // the browser hangs if the screen covers the entire document :/ documentHeight = this.document.height() - 1; if ( screenHeight < documentHeight ) { screen.height( documentHeight ); } else if ( popupHeight > screenHeight ) { screen.height( popupHeight ); } }
javascript
function() { var screen = this._ui.screen, popupHeight = this._ui.container.outerHeight( true ), screenHeight = screen.removeAttr( "style" ).height(), // Subtracting 1 here is necessary for an obscure Andrdoid 4.0 bug where // the browser hangs if the screen covers the entire document :/ documentHeight = this.document.height() - 1; if ( screenHeight < documentHeight ) { screen.height( documentHeight ); } else if ( popupHeight > screenHeight ) { screen.height( popupHeight ); } }
[ "function", "(", ")", "{", "var", "screen", "=", "this", ".", "_ui", ".", "screen", ",", "popupHeight", "=", "this", ".", "_ui", ".", "container", ".", "outerHeight", "(", "true", ")", ",", "screenHeight", "=", "screen", ".", "removeAttr", "(", "\"style\"", ")", ".", "height", "(", ")", ",", "// Subtracting 1 here is necessary for an obscure Andrdoid 4.0 bug where", "// the browser hangs if the screen covers the entire document :/", "documentHeight", "=", "this", ".", "document", ".", "height", "(", ")", "-", "1", ";", "if", "(", "screenHeight", "<", "documentHeight", ")", "{", "screen", ".", "height", "(", "documentHeight", ")", ";", "}", "else", "if", "(", "popupHeight", ">", "screenHeight", ")", "{", "screen", ".", "height", "(", "popupHeight", ")", ";", "}", "}" ]
Make sure the screen covers the entire document - CSS is sometimes not enough to accomplish this.
[ "Make", "sure", "the", "screen", "covers", "the", "entire", "document", "-", "CSS", "is", "sometimes", "not", "enough", "to", "accomplish", "this", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L17830-L17844
27,008
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function( theEvent ) { var target, targetElement = theEvent.target, ui = this._ui; if ( !this._isOpen ) { return; } if ( targetElement !== ui.container[ 0 ] ) { target = $( targetElement ); if ( !$.contains( ui.container[ 0 ], targetElement ) ) { $( this.document[ 0 ].activeElement ).one( "focus", $.proxy( function() { this._safelyBlur( targetElement ); }, this ) ); ui.focusElement.focus(); theEvent.preventDefault(); theEvent.stopImmediatePropagation(); return false; } else if ( ui.focusElement[ 0 ] === ui.container[ 0 ] ) { ui.focusElement = target; } } this._ignoreResizeEvents(); }
javascript
function( theEvent ) { var target, targetElement = theEvent.target, ui = this._ui; if ( !this._isOpen ) { return; } if ( targetElement !== ui.container[ 0 ] ) { target = $( targetElement ); if ( !$.contains( ui.container[ 0 ], targetElement ) ) { $( this.document[ 0 ].activeElement ).one( "focus", $.proxy( function() { this._safelyBlur( targetElement ); }, this ) ); ui.focusElement.focus(); theEvent.preventDefault(); theEvent.stopImmediatePropagation(); return false; } else if ( ui.focusElement[ 0 ] === ui.container[ 0 ] ) { ui.focusElement = target; } } this._ignoreResizeEvents(); }
[ "function", "(", "theEvent", ")", "{", "var", "target", ",", "targetElement", "=", "theEvent", ".", "target", ",", "ui", "=", "this", ".", "_ui", ";", "if", "(", "!", "this", ".", "_isOpen", ")", "{", "return", ";", "}", "if", "(", "targetElement", "!==", "ui", ".", "container", "[", "0", "]", ")", "{", "target", "=", "$", "(", "targetElement", ")", ";", "if", "(", "!", "$", ".", "contains", "(", "ui", ".", "container", "[", "0", "]", ",", "targetElement", ")", ")", "{", "$", "(", "this", ".", "document", "[", "0", "]", ".", "activeElement", ")", ".", "one", "(", "\"focus\"", ",", "$", ".", "proxy", "(", "function", "(", ")", "{", "this", ".", "_safelyBlur", "(", "targetElement", ")", ";", "}", ",", "this", ")", ")", ";", "ui", ".", "focusElement", ".", "focus", "(", ")", ";", "theEvent", ".", "preventDefault", "(", ")", ";", "theEvent", ".", "stopImmediatePropagation", "(", ")", ";", "return", "false", ";", "}", "else", "if", "(", "ui", ".", "focusElement", "[", "0", "]", "===", "ui", ".", "container", "[", "0", "]", ")", "{", "ui", ".", "focusElement", "=", "target", ";", "}", "}", "this", ".", "_ignoreResizeEvents", "(", ")", ";", "}" ]
When the popup is open, attempting to focus on an element that is not a child of the popup will redirect focus to the popup
[ "When", "the", "popup", "is", "open", "attempting", "to", "focus", "on", "an", "element", "that", "is", "not", "a", "child", "of", "the", "popup", "will", "redirect", "focus", "to", "the", "popup" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L17928-L17953
27,009
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function() { var ua = navigator.userAgent, platform = navigator.platform, // Rendering engine is Webkit, and capture major version wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ), wkversion = !!wkmatch && wkmatch[ 1 ], os = null, self = this; //set the os we are working in if it dosent match one with workarounds return if ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1 || platform.indexOf( "iPod" ) > -1 ) { os = "ios"; } else if ( ua.indexOf( "Android" ) > -1 ) { os = "android"; } else { return; } //check os version if it dosent match one with workarounds return if ( os === "ios" ) { //iOS workarounds self._bindScrollWorkaround(); } else if ( os === "android" && wkversion && wkversion < 534 ) { //Android 2.3 run all Android 2.3 workaround self._bindScrollWorkaround(); self._bindListThumbWorkaround(); } else { return; } }
javascript
function() { var ua = navigator.userAgent, platform = navigator.platform, // Rendering engine is Webkit, and capture major version wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ), wkversion = !!wkmatch && wkmatch[ 1 ], os = null, self = this; //set the os we are working in if it dosent match one with workarounds return if ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1 || platform.indexOf( "iPod" ) > -1 ) { os = "ios"; } else if ( ua.indexOf( "Android" ) > -1 ) { os = "android"; } else { return; } //check os version if it dosent match one with workarounds return if ( os === "ios" ) { //iOS workarounds self._bindScrollWorkaround(); } else if ( os === "android" && wkversion && wkversion < 534 ) { //Android 2.3 run all Android 2.3 workaround self._bindScrollWorkaround(); self._bindListThumbWorkaround(); } else { return; } }
[ "function", "(", ")", "{", "var", "ua", "=", "navigator", ".", "userAgent", ",", "platform", "=", "navigator", ".", "platform", ",", "// Rendering engine is Webkit, and capture major version", "wkmatch", "=", "ua", ".", "match", "(", "/", "AppleWebKit\\/([0-9]+)", "/", ")", ",", "wkversion", "=", "!", "!", "wkmatch", "&&", "wkmatch", "[", "1", "]", ",", "os", "=", "null", ",", "self", "=", "this", ";", "//set the os we are working in if it dosent match one with workarounds return", "if", "(", "platform", ".", "indexOf", "(", "\"iPhone\"", ")", ">", "-", "1", "||", "platform", ".", "indexOf", "(", "\"iPad\"", ")", ">", "-", "1", "||", "platform", ".", "indexOf", "(", "\"iPod\"", ")", ">", "-", "1", ")", "{", "os", "=", "\"ios\"", ";", "}", "else", "if", "(", "ua", ".", "indexOf", "(", "\"Android\"", ")", ">", "-", "1", ")", "{", "os", "=", "\"android\"", ";", "}", "else", "{", "return", ";", "}", "//check os version if it dosent match one with workarounds return", "if", "(", "os", "===", "\"ios\"", ")", "{", "//iOS workarounds", "self", ".", "_bindScrollWorkaround", "(", ")", ";", "}", "else", "if", "(", "os", "===", "\"android\"", "&&", "wkversion", "&&", "wkversion", "<", "534", ")", "{", "//Android 2.3 run all Android 2.3 workaround", "self", ".", "_bindScrollWorkaround", "(", ")", ";", "self", ".", "_bindListThumbWorkaround", "(", ")", ";", "}", "else", "{", "return", ";", "}", "}" ]
check the browser and version and run needed workarounds
[ "check", "the", "browser", "and", "version", "and", "run", "needed", "workarounds" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L20125-L20152
27,010
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function() { var $el = this.element, header = $el.hasClass( "ui-header" ), offset = Math.abs( $el.offset().top - this.window.scrollTop() ); if ( !header ) { offset = Math.round( offset - this.window.height() + $el.outerHeight() ) - 60; } return offset; }
javascript
function() { var $el = this.element, header = $el.hasClass( "ui-header" ), offset = Math.abs( $el.offset().top - this.window.scrollTop() ); if ( !header ) { offset = Math.round( offset - this.window.height() + $el.outerHeight() ) - 60; } return offset; }
[ "function", "(", ")", "{", "var", "$el", "=", "this", ".", "element", ",", "header", "=", "$el", ".", "hasClass", "(", "\"ui-header\"", ")", ",", "offset", "=", "Math", ".", "abs", "(", "$el", ".", "offset", "(", ")", ".", "top", "-", "this", ".", "window", ".", "scrollTop", "(", ")", ")", ";", "if", "(", "!", "header", ")", "{", "offset", "=", "Math", ".", "round", "(", "offset", "-", "this", ".", "window", ".", "height", "(", ")", "+", "$el", ".", "outerHeight", "(", ")", ")", "-", "60", ";", "}", "return", "offset", ";", "}" ]
Utility class for checking header and footer positions relative to viewport
[ "Utility", "class", "for", "checking", "header", "and", "footer", "positions", "relative", "to", "viewport" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L20155-L20163
27,011
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function( p, dir, desired, s, best ) { var result, r, diff, desiredForArrow = {}, tip = {}; // If the arrow has no wiggle room along the edge of the popup, it cannot // be displayed along the requested edge without it sticking out. if ( s.arFull[ p.dimKey ] > s.guideDims[ p.dimKey ] ) { return best; } desiredForArrow[ p.fst ] = desired[ p.fst ] + ( s.arHalf[ p.oDimKey ] + s.menuHalf[ p.oDimKey ] ) * p.offsetFactor - s.contentBox[ p.fst ] + ( s.clampInfo.menuSize[ p.oDimKey ] - s.contentBox[ p.oDimKey ] ) * p.arrowOffsetFactor; desiredForArrow[ p.snd ] = desired[ p.snd ]; result = s.result || this._calculateFinalLocation( desiredForArrow, s.clampInfo ); r = { x: result.left, y: result.top }; tip[ p.fst ] = r[ p.fst ] + s.contentBox[ p.fst ] + p.tipOffset; tip[ p.snd ] = Math.max( result[ p.prop ] + s.guideOffset[ p.prop ] + s.arHalf[ p.dimKey ], Math.min( result[ p.prop ] + s.guideOffset[ p.prop ] + s.guideDims[ p.dimKey ] - s.arHalf[ p.dimKey ], desired[ p.snd ] ) ); diff = Math.abs( desired.x - tip.x ) + Math.abs( desired.y - tip.y ); if ( !best || diff < best.diff ) { // Convert tip offset to coordinates inside the popup tip[ p.snd ] -= s.arHalf[ p.dimKey ] + result[ p.prop ] + s.contentBox[ p.snd ]; best = { dir: dir, diff: diff, result: result, posProp: p.prop, posVal: tip[ p.snd ] }; } return best; }
javascript
function( p, dir, desired, s, best ) { var result, r, diff, desiredForArrow = {}, tip = {}; // If the arrow has no wiggle room along the edge of the popup, it cannot // be displayed along the requested edge without it sticking out. if ( s.arFull[ p.dimKey ] > s.guideDims[ p.dimKey ] ) { return best; } desiredForArrow[ p.fst ] = desired[ p.fst ] + ( s.arHalf[ p.oDimKey ] + s.menuHalf[ p.oDimKey ] ) * p.offsetFactor - s.contentBox[ p.fst ] + ( s.clampInfo.menuSize[ p.oDimKey ] - s.contentBox[ p.oDimKey ] ) * p.arrowOffsetFactor; desiredForArrow[ p.snd ] = desired[ p.snd ]; result = s.result || this._calculateFinalLocation( desiredForArrow, s.clampInfo ); r = { x: result.left, y: result.top }; tip[ p.fst ] = r[ p.fst ] + s.contentBox[ p.fst ] + p.tipOffset; tip[ p.snd ] = Math.max( result[ p.prop ] + s.guideOffset[ p.prop ] + s.arHalf[ p.dimKey ], Math.min( result[ p.prop ] + s.guideOffset[ p.prop ] + s.guideDims[ p.dimKey ] - s.arHalf[ p.dimKey ], desired[ p.snd ] ) ); diff = Math.abs( desired.x - tip.x ) + Math.abs( desired.y - tip.y ); if ( !best || diff < best.diff ) { // Convert tip offset to coordinates inside the popup tip[ p.snd ] -= s.arHalf[ p.dimKey ] + result[ p.prop ] + s.contentBox[ p.snd ]; best = { dir: dir, diff: diff, result: result, posProp: p.prop, posVal: tip[ p.snd ] }; } return best; }
[ "function", "(", "p", ",", "dir", ",", "desired", ",", "s", ",", "best", ")", "{", "var", "result", ",", "r", ",", "diff", ",", "desiredForArrow", "=", "{", "}", ",", "tip", "=", "{", "}", ";", "// If the arrow has no wiggle room along the edge of the popup, it cannot", "// be displayed along the requested edge without it sticking out.", "if", "(", "s", ".", "arFull", "[", "p", ".", "dimKey", "]", ">", "s", ".", "guideDims", "[", "p", ".", "dimKey", "]", ")", "{", "return", "best", ";", "}", "desiredForArrow", "[", "p", ".", "fst", "]", "=", "desired", "[", "p", ".", "fst", "]", "+", "(", "s", ".", "arHalf", "[", "p", ".", "oDimKey", "]", "+", "s", ".", "menuHalf", "[", "p", ".", "oDimKey", "]", ")", "*", "p", ".", "offsetFactor", "-", "s", ".", "contentBox", "[", "p", ".", "fst", "]", "+", "(", "s", ".", "clampInfo", ".", "menuSize", "[", "p", ".", "oDimKey", "]", "-", "s", ".", "contentBox", "[", "p", ".", "oDimKey", "]", ")", "*", "p", ".", "arrowOffsetFactor", ";", "desiredForArrow", "[", "p", ".", "snd", "]", "=", "desired", "[", "p", ".", "snd", "]", ";", "result", "=", "s", ".", "result", "||", "this", ".", "_calculateFinalLocation", "(", "desiredForArrow", ",", "s", ".", "clampInfo", ")", ";", "r", "=", "{", "x", ":", "result", ".", "left", ",", "y", ":", "result", ".", "top", "}", ";", "tip", "[", "p", ".", "fst", "]", "=", "r", "[", "p", ".", "fst", "]", "+", "s", ".", "contentBox", "[", "p", ".", "fst", "]", "+", "p", ".", "tipOffset", ";", "tip", "[", "p", ".", "snd", "]", "=", "Math", ".", "max", "(", "result", "[", "p", ".", "prop", "]", "+", "s", ".", "guideOffset", "[", "p", ".", "prop", "]", "+", "s", ".", "arHalf", "[", "p", ".", "dimKey", "]", ",", "Math", ".", "min", "(", "result", "[", "p", ".", "prop", "]", "+", "s", ".", "guideOffset", "[", "p", ".", "prop", "]", "+", "s", ".", "guideDims", "[", "p", ".", "dimKey", "]", "-", "s", ".", "arHalf", "[", "p", ".", "dimKey", "]", ",", "desired", "[", "p", ".", "snd", "]", ")", ")", ";", "diff", "=", "Math", ".", "abs", "(", "desired", ".", "x", "-", "tip", ".", "x", ")", "+", "Math", ".", "abs", "(", "desired", ".", "y", "-", "tip", ".", "y", ")", ";", "if", "(", "!", "best", "||", "diff", "<", "best", ".", "diff", ")", "{", "// Convert tip offset to coordinates inside the popup", "tip", "[", "p", ".", "snd", "]", "-=", "s", ".", "arHalf", "[", "p", ".", "dimKey", "]", "+", "result", "[", "p", ".", "prop", "]", "+", "s", ".", "contentBox", "[", "p", ".", "snd", "]", ";", "best", "=", "{", "dir", ":", "dir", ",", "diff", ":", "diff", ",", "result", ":", "result", ",", "posProp", ":", "p", ".", "prop", ",", "posVal", ":", "tip", "[", "p", ".", "snd", "]", "}", ";", "}", "return", "best", ";", "}" ]
Pretend to show an arrow described by @p and @dir and calculate the distance from the desired point. If a best-distance is passed in, return the minimum of the one passed in and the one calculated.
[ "Pretend", "to", "show", "an", "arrow", "described", "by" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L20273-L20303
27,012
sony/cdp-js
packages/cdp-mobile/dist/cdp.js
function (event) { var target = event.target; var e = event; var ev; // [CDP modified]: set target.clientX. if (null == target.clientX || null == target.clientY) { if (null != e.pageX && null != e.pageY) { target.clientX = e.pageX; target.clientY = e.pageY; } else if (e.changedTouches && e.changedTouches[0]) { target.clientX = e.changedTouches[0].pageX; target.clientY = e.changedTouches[0].pageY; } } if (!(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName)) { ev = document.createEvent("MouseEvents"); ev.initMouseEvent("click", true, true, e.view, 1, target.screenX, target.screenY, target.clientX, target.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, 0, null); ev._constructed = true; target.dispatchEvent(ev); } }
javascript
function (event) { var target = event.target; var e = event; var ev; // [CDP modified]: set target.clientX. if (null == target.clientX || null == target.clientY) { if (null != e.pageX && null != e.pageY) { target.clientX = e.pageX; target.clientY = e.pageY; } else if (e.changedTouches && e.changedTouches[0]) { target.clientX = e.changedTouches[0].pageX; target.clientY = e.changedTouches[0].pageY; } } if (!(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName)) { ev = document.createEvent("MouseEvents"); ev.initMouseEvent("click", true, true, e.view, 1, target.screenX, target.screenY, target.clientX, target.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, 0, null); ev._constructed = true; target.dispatchEvent(ev); } }
[ "function", "(", "event", ")", "{", "var", "target", "=", "event", ".", "target", ";", "var", "e", "=", "event", ";", "var", "ev", ";", "// [CDP modified]: set target.clientX.", "if", "(", "null", "==", "target", ".", "clientX", "||", "null", "==", "target", ".", "clientY", ")", "{", "if", "(", "null", "!=", "e", ".", "pageX", "&&", "null", "!=", "e", ".", "pageY", ")", "{", "target", ".", "clientX", "=", "e", ".", "pageX", ";", "target", ".", "clientY", "=", "e", ".", "pageY", ";", "}", "else", "if", "(", "e", ".", "changedTouches", "&&", "e", ".", "changedTouches", "[", "0", "]", ")", "{", "target", ".", "clientX", "=", "e", ".", "changedTouches", "[", "0", "]", ".", "pageX", ";", "target", ".", "clientY", "=", "e", ".", "changedTouches", "[", "0", "]", ".", "pageY", ";", "}", "}", "if", "(", "!", "(", "/", "(SELECT|INPUT|TEXTAREA)", "/", "i", ")", ".", "test", "(", "target", ".", "tagName", ")", ")", "{", "ev", "=", "document", ".", "createEvent", "(", "\"MouseEvents\"", ")", ";", "ev", ".", "initMouseEvent", "(", "\"click\"", ",", "true", ",", "true", ",", "e", ".", "view", ",", "1", ",", "target", ".", "screenX", ",", "target", ".", "screenY", ",", "target", ".", "clientX", ",", "target", ".", "clientY", ",", "e", ".", "ctrlKey", ",", "e", ".", "altKey", ",", "e", ".", "shiftKey", ",", "e", ".", "metaKey", ",", "0", ",", "null", ")", ";", "ev", ".", "_constructed", "=", "true", ";", "target", ".", "dispatchEvent", "(", "ev", ")", ";", "}", "}" ]
! iScroll.click patch
[ "!", "iScroll", ".", "click", "patch" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-mobile/dist/cdp.js#L29662-L29683
27,013
sony/cdp-js
packages/master-tasks/provider.js
setupByCopy
function setupByCopy() { let task_dir; let required_tasks; try { const config = require(path.join(process.cwd(), 'project.config')); required_tasks = config.required_tasks; if (!required_tasks) { throw Error('no task required.'); } task_dir = config.dir.task; if (!task_dir) { throw Error('task directory not defined.'); } } catch (error) { console.warn(error); process.exit(0); } const dstTaskDir = path.join(process.cwd(), task_dir); if (!fs.existsSync(dstTaskDir)) { // create tasks dir fs.mkdirSync(dstTaskDir); } required_tasks.forEach((task) => { const src = path.join(__dirname, 'tasks', task); const dst = path.join(dstTaskDir, task); if (fs.existsSync(src)) { if (fs.existsSync(dst)) { fs.unlinkSync(dst); } fs.writeFileSync(dst, fs.readFileSync(src).toString()); } else { console.error('task not found: ' + task); process.exit(1); } }); }
javascript
function setupByCopy() { let task_dir; let required_tasks; try { const config = require(path.join(process.cwd(), 'project.config')); required_tasks = config.required_tasks; if (!required_tasks) { throw Error('no task required.'); } task_dir = config.dir.task; if (!task_dir) { throw Error('task directory not defined.'); } } catch (error) { console.warn(error); process.exit(0); } const dstTaskDir = path.join(process.cwd(), task_dir); if (!fs.existsSync(dstTaskDir)) { // create tasks dir fs.mkdirSync(dstTaskDir); } required_tasks.forEach((task) => { const src = path.join(__dirname, 'tasks', task); const dst = path.join(dstTaskDir, task); if (fs.existsSync(src)) { if (fs.existsSync(dst)) { fs.unlinkSync(dst); } fs.writeFileSync(dst, fs.readFileSync(src).toString()); } else { console.error('task not found: ' + task); process.exit(1); } }); }
[ "function", "setupByCopy", "(", ")", "{", "let", "task_dir", ";", "let", "required_tasks", ";", "try", "{", "const", "config", "=", "require", "(", "path", ".", "join", "(", "process", ".", "cwd", "(", ")", ",", "'project.config'", ")", ")", ";", "required_tasks", "=", "config", ".", "required_tasks", ";", "if", "(", "!", "required_tasks", ")", "{", "throw", "Error", "(", "'no task required.'", ")", ";", "}", "task_dir", "=", "config", ".", "dir", ".", "task", ";", "if", "(", "!", "task_dir", ")", "{", "throw", "Error", "(", "'task directory not defined.'", ")", ";", "}", "}", "catch", "(", "error", ")", "{", "console", ".", "warn", "(", "error", ")", ";", "process", ".", "exit", "(", "0", ")", ";", "}", "const", "dstTaskDir", "=", "path", ".", "join", "(", "process", ".", "cwd", "(", ")", ",", "task_dir", ")", ";", "if", "(", "!", "fs", ".", "existsSync", "(", "dstTaskDir", ")", ")", "{", "// create tasks dir", "fs", ".", "mkdirSync", "(", "dstTaskDir", ")", ";", "}", "required_tasks", ".", "forEach", "(", "(", "task", ")", "=>", "{", "const", "src", "=", "path", ".", "join", "(", "__dirname", ",", "'tasks'", ",", "task", ")", ";", "const", "dst", "=", "path", ".", "join", "(", "dstTaskDir", ",", "task", ")", ";", "if", "(", "fs", ".", "existsSync", "(", "src", ")", ")", "{", "if", "(", "fs", ".", "existsSync", "(", "dst", ")", ")", "{", "fs", ".", "unlinkSync", "(", "dst", ")", ";", "}", "fs", ".", "writeFileSync", "(", "dst", ",", "fs", ".", "readFileSync", "(", "src", ")", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "console", ".", "error", "(", "'task not found: '", "+", "task", ")", ";", "process", ".", "exit", "(", "1", ")", ";", "}", "}", ")", ";", "}" ]
call from packages
[ "call", "from", "packages" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/master-tasks/provider.js#L31-L69
27,014
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function () { var encTable = this._tables[0], decTable = this._tables[1], sbox = encTable[4], sboxInv = decTable[4], i, x, xInv, d=[], th=[], x2, x4, x8, s, tEnc, tDec; // Compute double and third tables for (i = 0; i < 256; i++) { th[( d[i] = i<<1 ^ (i>>7)*283 )^i]=i; } for (x = xInv = 0; !sbox[x]; x ^= x2 || 1, xInv = th[xInv] || 1) { // Compute sbox s = xInv ^ xInv<<1 ^ xInv<<2 ^ xInv<<3 ^ xInv<<4; s = s>>8 ^ s&255 ^ 99; sbox[x] = s; sboxInv[s] = x; // Compute MixColumns x8 = d[x4 = d[x2 = d[x]]]; tDec = x8*0x1010101 ^ x4*0x10001 ^ x2*0x101 ^ x*0x1010100; tEnc = d[s]*0x101 ^ s*0x1010100; for (i = 0; i < 4; i++) { encTable[i][x] = tEnc = tEnc<<24 ^ tEnc>>>8; decTable[i][s] = tDec = tDec<<24 ^ tDec>>>8; } } // Compactify. Considerable speedup on Firefox. for (i = 0; i < 5; i++) { encTable[i] = encTable[i].slice(0); decTable[i] = decTable[i].slice(0); } }
javascript
function () { var encTable = this._tables[0], decTable = this._tables[1], sbox = encTable[4], sboxInv = decTable[4], i, x, xInv, d=[], th=[], x2, x4, x8, s, tEnc, tDec; // Compute double and third tables for (i = 0; i < 256; i++) { th[( d[i] = i<<1 ^ (i>>7)*283 )^i]=i; } for (x = xInv = 0; !sbox[x]; x ^= x2 || 1, xInv = th[xInv] || 1) { // Compute sbox s = xInv ^ xInv<<1 ^ xInv<<2 ^ xInv<<3 ^ xInv<<4; s = s>>8 ^ s&255 ^ 99; sbox[x] = s; sboxInv[s] = x; // Compute MixColumns x8 = d[x4 = d[x2 = d[x]]]; tDec = x8*0x1010101 ^ x4*0x10001 ^ x2*0x101 ^ x*0x1010100; tEnc = d[s]*0x101 ^ s*0x1010100; for (i = 0; i < 4; i++) { encTable[i][x] = tEnc = tEnc<<24 ^ tEnc>>>8; decTable[i][s] = tDec = tDec<<24 ^ tDec>>>8; } } // Compactify. Considerable speedup on Firefox. for (i = 0; i < 5; i++) { encTable[i] = encTable[i].slice(0); decTable[i] = decTable[i].slice(0); } }
[ "function", "(", ")", "{", "var", "encTable", "=", "this", ".", "_tables", "[", "0", "]", ",", "decTable", "=", "this", ".", "_tables", "[", "1", "]", ",", "sbox", "=", "encTable", "[", "4", "]", ",", "sboxInv", "=", "decTable", "[", "4", "]", ",", "i", ",", "x", ",", "xInv", ",", "d", "=", "[", "]", ",", "th", "=", "[", "]", ",", "x2", ",", "x4", ",", "x8", ",", "s", ",", "tEnc", ",", "tDec", ";", "// Compute double and third tables", "for", "(", "i", "=", "0", ";", "i", "<", "256", ";", "i", "++", ")", "{", "th", "[", "(", "d", "[", "i", "]", "=", "i", "<<", "1", "^", "(", "i", ">>", "7", ")", "*", "283", ")", "^", "i", "]", "=", "i", ";", "}", "for", "(", "x", "=", "xInv", "=", "0", ";", "!", "sbox", "[", "x", "]", ";", "x", "^=", "x2", "||", "1", ",", "xInv", "=", "th", "[", "xInv", "]", "||", "1", ")", "{", "// Compute sbox", "s", "=", "xInv", "^", "xInv", "<<", "1", "^", "xInv", "<<", "2", "^", "xInv", "<<", "3", "^", "xInv", "<<", "4", ";", "s", "=", "s", ">>", "8", "^", "s", "&", "255", "^", "99", ";", "sbox", "[", "x", "]", "=", "s", ";", "sboxInv", "[", "s", "]", "=", "x", ";", "// Compute MixColumns", "x8", "=", "d", "[", "x4", "=", "d", "[", "x2", "=", "d", "[", "x", "]", "]", "]", ";", "tDec", "=", "x8", "*", "0x1010101", "^", "x4", "*", "0x10001", "^", "x2", "*", "0x101", "^", "x", "*", "0x1010100", ";", "tEnc", "=", "d", "[", "s", "]", "*", "0x101", "^", "s", "*", "0x1010100", ";", "for", "(", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "encTable", "[", "i", "]", "[", "x", "]", "=", "tEnc", "=", "tEnc", "<<", "24", "^", "tEnc", ">>>", "8", ";", "decTable", "[", "i", "]", "[", "s", "]", "=", "tDec", "=", "tDec", "<<", "24", "^", "tDec", ">>>", "8", ";", "}", "}", "// Compactify. Considerable speedup on Firefox.", "for", "(", "i", "=", "0", ";", "i", "<", "5", ";", "i", "++", ")", "{", "encTable", "[", "i", "]", "=", "encTable", "[", "i", "]", ".", "slice", "(", "0", ")", ";", "decTable", "[", "i", "]", "=", "decTable", "[", "i", "]", ".", "slice", "(", "0", ")", ";", "}", "}" ]
Expand the S-box tables. @private
[ "Expand", "the", "S", "-", "box", "tables", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L199-L232
27,015
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (input, dir) { if (input.length !== 4) { throw new sjcl.exception.invalid("invalid aes block size"); } var key = this._key[dir], // state variables a,b,c,d are loaded with pre-whitened data a = input[0] ^ key[0], b = input[dir ? 3 : 1] ^ key[1], c = input[2] ^ key[2], d = input[dir ? 1 : 3] ^ key[3], a2, b2, c2, nInnerRounds = key.length/4 - 2, i, kIndex = 4, out = [0,0,0,0], table = this._tables[dir], // load up the tables t0 = table[0], t1 = table[1], t2 = table[2], t3 = table[3], sbox = table[4]; // Inner rounds. Cribbed from OpenSSL. for (i = 0; i < nInnerRounds; i++) { a2 = t0[a>>>24] ^ t1[b>>16 & 255] ^ t2[c>>8 & 255] ^ t3[d & 255] ^ key[kIndex]; b2 = t0[b>>>24] ^ t1[c>>16 & 255] ^ t2[d>>8 & 255] ^ t3[a & 255] ^ key[kIndex + 1]; c2 = t0[c>>>24] ^ t1[d>>16 & 255] ^ t2[a>>8 & 255] ^ t3[b & 255] ^ key[kIndex + 2]; d = t0[d>>>24] ^ t1[a>>16 & 255] ^ t2[b>>8 & 255] ^ t3[c & 255] ^ key[kIndex + 3]; kIndex += 4; a=a2; b=b2; c=c2; } // Last round. for (i = 0; i < 4; i++) { out[dir ? 3&-i : i] = sbox[a>>>24 ]<<24 ^ sbox[b>>16 & 255]<<16 ^ sbox[c>>8 & 255]<<8 ^ sbox[d & 255] ^ key[kIndex++]; a2=a; a=b; b=c; c=d; d=a2; } return out; }
javascript
function (input, dir) { if (input.length !== 4) { throw new sjcl.exception.invalid("invalid aes block size"); } var key = this._key[dir], // state variables a,b,c,d are loaded with pre-whitened data a = input[0] ^ key[0], b = input[dir ? 3 : 1] ^ key[1], c = input[2] ^ key[2], d = input[dir ? 1 : 3] ^ key[3], a2, b2, c2, nInnerRounds = key.length/4 - 2, i, kIndex = 4, out = [0,0,0,0], table = this._tables[dir], // load up the tables t0 = table[0], t1 = table[1], t2 = table[2], t3 = table[3], sbox = table[4]; // Inner rounds. Cribbed from OpenSSL. for (i = 0; i < nInnerRounds; i++) { a2 = t0[a>>>24] ^ t1[b>>16 & 255] ^ t2[c>>8 & 255] ^ t3[d & 255] ^ key[kIndex]; b2 = t0[b>>>24] ^ t1[c>>16 & 255] ^ t2[d>>8 & 255] ^ t3[a & 255] ^ key[kIndex + 1]; c2 = t0[c>>>24] ^ t1[d>>16 & 255] ^ t2[a>>8 & 255] ^ t3[b & 255] ^ key[kIndex + 2]; d = t0[d>>>24] ^ t1[a>>16 & 255] ^ t2[b>>8 & 255] ^ t3[c & 255] ^ key[kIndex + 3]; kIndex += 4; a=a2; b=b2; c=c2; } // Last round. for (i = 0; i < 4; i++) { out[dir ? 3&-i : i] = sbox[a>>>24 ]<<24 ^ sbox[b>>16 & 255]<<16 ^ sbox[c>>8 & 255]<<8 ^ sbox[d & 255] ^ key[kIndex++]; a2=a; a=b; b=c; c=d; d=a2; } return out; }
[ "function", "(", "input", ",", "dir", ")", "{", "if", "(", "input", ".", "length", "!==", "4", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "invalid", "(", "\"invalid aes block size\"", ")", ";", "}", "var", "key", "=", "this", ".", "_key", "[", "dir", "]", ",", "// state variables a,b,c,d are loaded with pre-whitened data", "a", "=", "input", "[", "0", "]", "^", "key", "[", "0", "]", ",", "b", "=", "input", "[", "dir", "?", "3", ":", "1", "]", "^", "key", "[", "1", "]", ",", "c", "=", "input", "[", "2", "]", "^", "key", "[", "2", "]", ",", "d", "=", "input", "[", "dir", "?", "1", ":", "3", "]", "^", "key", "[", "3", "]", ",", "a2", ",", "b2", ",", "c2", ",", "nInnerRounds", "=", "key", ".", "length", "/", "4", "-", "2", ",", "i", ",", "kIndex", "=", "4", ",", "out", "=", "[", "0", ",", "0", ",", "0", ",", "0", "]", ",", "table", "=", "this", ".", "_tables", "[", "dir", "]", ",", "// load up the tables", "t0", "=", "table", "[", "0", "]", ",", "t1", "=", "table", "[", "1", "]", ",", "t2", "=", "table", "[", "2", "]", ",", "t3", "=", "table", "[", "3", "]", ",", "sbox", "=", "table", "[", "4", "]", ";", "// Inner rounds. Cribbed from OpenSSL.", "for", "(", "i", "=", "0", ";", "i", "<", "nInnerRounds", ";", "i", "++", ")", "{", "a2", "=", "t0", "[", "a", ">>>", "24", "]", "^", "t1", "[", "b", ">>", "16", "&", "255", "]", "^", "t2", "[", "c", ">>", "8", "&", "255", "]", "^", "t3", "[", "d", "&", "255", "]", "^", "key", "[", "kIndex", "]", ";", "b2", "=", "t0", "[", "b", ">>>", "24", "]", "^", "t1", "[", "c", ">>", "16", "&", "255", "]", "^", "t2", "[", "d", ">>", "8", "&", "255", "]", "^", "t3", "[", "a", "&", "255", "]", "^", "key", "[", "kIndex", "+", "1", "]", ";", "c2", "=", "t0", "[", "c", ">>>", "24", "]", "^", "t1", "[", "d", ">>", "16", "&", "255", "]", "^", "t2", "[", "a", ">>", "8", "&", "255", "]", "^", "t3", "[", "b", "&", "255", "]", "^", "key", "[", "kIndex", "+", "2", "]", ";", "d", "=", "t0", "[", "d", ">>>", "24", "]", "^", "t1", "[", "a", ">>", "16", "&", "255", "]", "^", "t2", "[", "b", ">>", "8", "&", "255", "]", "^", "t3", "[", "c", "&", "255", "]", "^", "key", "[", "kIndex", "+", "3", "]", ";", "kIndex", "+=", "4", ";", "a", "=", "a2", ";", "b", "=", "b2", ";", "c", "=", "c2", ";", "}", "// Last round.", "for", "(", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "out", "[", "dir", "?", "3", "&", "-", "i", ":", "i", "]", "=", "sbox", "[", "a", ">>>", "24", "]", "<<", "24", "^", "sbox", "[", "b", ">>", "16", "&", "255", "]", "<<", "16", "^", "sbox", "[", "c", ">>", "8", "&", "255", "]", "<<", "8", "^", "sbox", "[", "d", "&", "255", "]", "^", "key", "[", "kIndex", "++", "]", ";", "a2", "=", "a", ";", "a", "=", "b", ";", "b", "=", "c", ";", "c", "=", "d", ";", "d", "=", "a2", ";", "}", "return", "out", ";", "}" ]
Encryption and decryption core. @param {Array} input Four words to be encrypted or decrypted. @param dir The direction, 0 for encrypt and 1 for decrypt. @return {Array} The four encrypted or decrypted words. @private
[ "Encryption", "and", "decryption", "core", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L241-L289
27,016
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (a, bstart, bend) { a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1); return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart); }
javascript
function (a, bstart, bend) { a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1); return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart); }
[ "function", "(", "a", ",", "bstart", ",", "bend", ")", "{", "a", "=", "sjcl", ".", "bitArray", ".", "_shiftRight", "(", "a", ".", "slice", "(", "bstart", "/", "32", ")", ",", "32", "-", "(", "bstart", "&", "31", ")", ")", ".", "slice", "(", "1", ")", ";", "return", "(", "bend", "===", "undefined", ")", "?", "a", ":", "sjcl", ".", "bitArray", ".", "clamp", "(", "a", ",", "bend", "-", "bstart", ")", ";", "}" ]
Array slices in units of bits. @param {bitArray} a The array to slice. @param {Number} bstart The offset to the start of the slice, in bits. @param {Number} bend The offset to the end of the slice, in bits. If this is undefined, slice until the end of the array. @return {bitArray} The requested slice.
[ "Array", "slices", "in", "units", "of", "bits", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L331-L334
27,017
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(a, bstart, blength) { // FIXME: this Math.floor is not necessary at all, but for some reason // seems to suppress a bug in the Chromium JIT. var x, sh = Math.floor((-bstart-blength) & 31); if ((bstart + blength - 1 ^ bstart) & -32) { // it crosses a boundary x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh); } else { // within a single word x = a[bstart/32|0] >>> sh; } return x & ((1<<blength) - 1); }
javascript
function(a, bstart, blength) { // FIXME: this Math.floor is not necessary at all, but for some reason // seems to suppress a bug in the Chromium JIT. var x, sh = Math.floor((-bstart-blength) & 31); if ((bstart + blength - 1 ^ bstart) & -32) { // it crosses a boundary x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh); } else { // within a single word x = a[bstart/32|0] >>> sh; } return x & ((1<<blength) - 1); }
[ "function", "(", "a", ",", "bstart", ",", "blength", ")", "{", "// FIXME: this Math.floor is not necessary at all, but for some reason", "// seems to suppress a bug in the Chromium JIT.", "var", "x", ",", "sh", "=", "Math", ".", "floor", "(", "(", "-", "bstart", "-", "blength", ")", "&", "31", ")", ";", "if", "(", "(", "bstart", "+", "blength", "-", "1", "^", "bstart", ")", "&", "-", "32", ")", "{", "// it crosses a boundary", "x", "=", "(", "a", "[", "bstart", "/", "32", "|", "0", "]", "<<", "(", "32", "-", "sh", ")", ")", "^", "(", "a", "[", "bstart", "/", "32", "+", "1", "|", "0", "]", ">>>", "sh", ")", ";", "}", "else", "{", "// within a single word", "x", "=", "a", "[", "bstart", "/", "32", "|", "0", "]", ">>>", "sh", ";", "}", "return", "x", "&", "(", "(", "1", "<<", "blength", ")", "-", "1", ")", ";", "}" ]
Extract a number packed into a bit array. @param {bitArray} a The array to slice. @param {Number} bstart The offset to the start of the slice, in bits. @param {Number} length The length of the number to extract. @return {Number} The requested slice.
[ "Extract", "a", "number", "packed", "into", "a", "bit", "array", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L343-L355
27,018
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (a1, a2) { if (a1.length === 0 || a2.length === 0) { return a1.concat(a2); } var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last); if (shift === 32) { return a1.concat(a2); } else { return sjcl.bitArray._shiftRight(a2, shift, last|0, a1.slice(0,a1.length-1)); } }
javascript
function (a1, a2) { if (a1.length === 0 || a2.length === 0) { return a1.concat(a2); } var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last); if (shift === 32) { return a1.concat(a2); } else { return sjcl.bitArray._shiftRight(a2, shift, last|0, a1.slice(0,a1.length-1)); } }
[ "function", "(", "a1", ",", "a2", ")", "{", "if", "(", "a1", ".", "length", "===", "0", "||", "a2", ".", "length", "===", "0", ")", "{", "return", "a1", ".", "concat", "(", "a2", ")", ";", "}", "var", "last", "=", "a1", "[", "a1", ".", "length", "-", "1", "]", ",", "shift", "=", "sjcl", ".", "bitArray", ".", "getPartial", "(", "last", ")", ";", "if", "(", "shift", "===", "32", ")", "{", "return", "a1", ".", "concat", "(", "a2", ")", ";", "}", "else", "{", "return", "sjcl", ".", "bitArray", ".", "_shiftRight", "(", "a2", ",", "shift", ",", "last", "|", "0", ",", "a1", ".", "slice", "(", "0", ",", "a1", ".", "length", "-", "1", ")", ")", ";", "}", "}" ]
Concatenate two bit arrays. @param {bitArray} a1 The first array. @param {bitArray} a2 The second array. @return {bitArray} The concatenation of a1 and a2.
[ "Concatenate", "two", "bit", "arrays", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L363-L374
27,019
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (a) { var l = a.length, x; if (l === 0) { return 0; } x = a[l - 1]; return (l-1) * 32 + sjcl.bitArray.getPartial(x); }
javascript
function (a) { var l = a.length, x; if (l === 0) { return 0; } x = a[l - 1]; return (l-1) * 32 + sjcl.bitArray.getPartial(x); }
[ "function", "(", "a", ")", "{", "var", "l", "=", "a", ".", "length", ",", "x", ";", "if", "(", "l", "===", "0", ")", "{", "return", "0", ";", "}", "x", "=", "a", "[", "l", "-", "1", "]", ";", "return", "(", "l", "-", "1", ")", "*", "32", "+", "sjcl", ".", "bitArray", ".", "getPartial", "(", "x", ")", ";", "}" ]
Find the length of an array of bits. @param {bitArray} a The array. @return {Number} The length of a, in bits.
[ "Find", "the", "length", "of", "an", "array", "of", "bits", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L381-L386
27,020
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (a, len) { if (a.length * 32 < len) { return a; } a = a.slice(0, Math.ceil(len / 32)); var l = a.length; len = len & 31; if (l > 0 && len) { a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1); } return a; }
javascript
function (a, len) { if (a.length * 32 < len) { return a; } a = a.slice(0, Math.ceil(len / 32)); var l = a.length; len = len & 31; if (l > 0 && len) { a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1); } return a; }
[ "function", "(", "a", ",", "len", ")", "{", "if", "(", "a", ".", "length", "*", "32", "<", "len", ")", "{", "return", "a", ";", "}", "a", "=", "a", ".", "slice", "(", "0", ",", "Math", ".", "ceil", "(", "len", "/", "32", ")", ")", ";", "var", "l", "=", "a", ".", "length", ";", "len", "=", "len", "&", "31", ";", "if", "(", "l", ">", "0", "&&", "len", ")", "{", "a", "[", "l", "-", "1", "]", "=", "sjcl", ".", "bitArray", ".", "partial", "(", "len", ",", "a", "[", "l", "-", "1", "]", "&", "0x80000000", ">>", "(", "len", "-", "1", ")", ",", "1", ")", ";", "}", "return", "a", ";", "}" ]
Truncate an array. @param {bitArray} a The array. @param {Number} len The length to truncate to, in bits. @return {bitArray} A new array, truncated to len bits.
[ "Truncate", "an", "array", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L394-L403
27,021
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (a, b) { if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) { return false; } var x = 0, i; for (i=0; i<a.length; i++) { x |= a[i]^b[i]; } return (x === 0); }
javascript
function (a, b) { if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) { return false; } var x = 0, i; for (i=0; i<a.length; i++) { x |= a[i]^b[i]; } return (x === 0); }
[ "function", "(", "a", ",", "b", ")", "{", "if", "(", "sjcl", ".", "bitArray", ".", "bitLength", "(", "a", ")", "!==", "sjcl", ".", "bitArray", ".", "bitLength", "(", "b", ")", ")", "{", "return", "false", ";", "}", "var", "x", "=", "0", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "a", ".", "length", ";", "i", "++", ")", "{", "x", "|=", "a", "[", "i", "]", "^", "b", "[", "i", "]", ";", "}", "return", "(", "x", "===", "0", ")", ";", "}" ]
Compare two arrays for equality in a predictable amount of time. @param {bitArray} a The first array. @param {bitArray} b The second array. @return {boolean} true if a == b; false otherwise.
[ "Compare", "two", "arrays", "for", "equality", "in", "a", "predictable", "amount", "of", "time", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L432-L441
27,022
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (a, shift, carry, out) { var i, last2=0, shift2; if (out === undefined) { out = []; } for (; shift >= 32; shift -= 32) { out.push(carry); carry = 0; } if (shift === 0) { return out.concat(a); } for (i=0; i<a.length; i++) { out.push(carry | a[i]>>>shift); carry = a[i] << (32-shift); } last2 = a.length ? a[a.length-1] : 0; shift2 = sjcl.bitArray.getPartial(last2); out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1)); return out; }
javascript
function (a, shift, carry, out) { var i, last2=0, shift2; if (out === undefined) { out = []; } for (; shift >= 32; shift -= 32) { out.push(carry); carry = 0; } if (shift === 0) { return out.concat(a); } for (i=0; i<a.length; i++) { out.push(carry | a[i]>>>shift); carry = a[i] << (32-shift); } last2 = a.length ? a[a.length-1] : 0; shift2 = sjcl.bitArray.getPartial(last2); out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1)); return out; }
[ "function", "(", "a", ",", "shift", ",", "carry", ",", "out", ")", "{", "var", "i", ",", "last2", "=", "0", ",", "shift2", ";", "if", "(", "out", "===", "undefined", ")", "{", "out", "=", "[", "]", ";", "}", "for", "(", ";", "shift", ">=", "32", ";", "shift", "-=", "32", ")", "{", "out", ".", "push", "(", "carry", ")", ";", "carry", "=", "0", ";", "}", "if", "(", "shift", "===", "0", ")", "{", "return", "out", ".", "concat", "(", "a", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "a", ".", "length", ";", "i", "++", ")", "{", "out", ".", "push", "(", "carry", "|", "a", "[", "i", "]", ">>>", "shift", ")", ";", "carry", "=", "a", "[", "i", "]", "<<", "(", "32", "-", "shift", ")", ";", "}", "last2", "=", "a", ".", "length", "?", "a", "[", "a", ".", "length", "-", "1", "]", ":", "0", ";", "shift2", "=", "sjcl", ".", "bitArray", ".", "getPartial", "(", "last2", ")", ";", "out", ".", "push", "(", "sjcl", ".", "bitArray", ".", "partial", "(", "shift", "+", "shift2", "&", "31", ",", "(", "shift", "+", "shift2", ">", "32", ")", "?", "carry", ":", "out", ".", "pop", "(", ")", ",", "1", ")", ")", ";", "return", "out", ";", "}" ]
Shift an array right. @param {bitArray} a The array to shift. @param {Number} shift The number of bits to shift. @param {Number} [carry=0] A byte to carry in @param {bitArray} [out=[]] An array to prepend to the output. @private
[ "Shift", "an", "array", "right", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L450-L470
27,023
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (arr) { var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp; for (i=0; i<bl/8; i++) { if ((i&3) === 0) { tmp = arr[i/4]; } out += String.fromCharCode(tmp >>> 24); tmp <<= 8; } return decodeURIComponent(escape(out)); }
javascript
function (arr) { var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp; for (i=0; i<bl/8; i++) { if ((i&3) === 0) { tmp = arr[i/4]; } out += String.fromCharCode(tmp >>> 24); tmp <<= 8; } return decodeURIComponent(escape(out)); }
[ "function", "(", "arr", ")", "{", "var", "out", "=", "\"\"", ",", "bl", "=", "sjcl", ".", "bitArray", ".", "bitLength", "(", "arr", ")", ",", "i", ",", "tmp", ";", "for", "(", "i", "=", "0", ";", "i", "<", "bl", "/", "8", ";", "i", "++", ")", "{", "if", "(", "(", "i", "&", "3", ")", "===", "0", ")", "{", "tmp", "=", "arr", "[", "i", "/", "4", "]", ";", "}", "out", "+=", "String", ".", "fromCharCode", "(", "tmp", ">>>", "24", ")", ";", "tmp", "<<=", "8", ";", "}", "return", "decodeURIComponent", "(", "escape", "(", "out", ")", ")", ";", "}" ]
Convert from a bitArray to a UTF-8 string.
[ "Convert", "from", "a", "bitArray", "to", "a", "UTF", "-", "8", "string", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L503-L513
27,024
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (str) { str = unescape(encodeURIComponent(str)); var out = [], i, tmp=0; for (i=0; i<str.length; i++) { tmp = tmp << 8 | str.charCodeAt(i); if ((i&3) === 3) { out.push(tmp); tmp = 0; } } if (i&3) { out.push(sjcl.bitArray.partial(8*(i&3), tmp)); } return out; }
javascript
function (str) { str = unescape(encodeURIComponent(str)); var out = [], i, tmp=0; for (i=0; i<str.length; i++) { tmp = tmp << 8 | str.charCodeAt(i); if ((i&3) === 3) { out.push(tmp); tmp = 0; } } if (i&3) { out.push(sjcl.bitArray.partial(8*(i&3), tmp)); } return out; }
[ "function", "(", "str", ")", "{", "str", "=", "unescape", "(", "encodeURIComponent", "(", "str", ")", ")", ";", "var", "out", "=", "[", "]", ",", "i", ",", "tmp", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "str", ".", "length", ";", "i", "++", ")", "{", "tmp", "=", "tmp", "<<", "8", "|", "str", ".", "charCodeAt", "(", "i", ")", ";", "if", "(", "(", "i", "&", "3", ")", "===", "3", ")", "{", "out", ".", "push", "(", "tmp", ")", ";", "tmp", "=", "0", ";", "}", "}", "if", "(", "i", "&", "3", ")", "{", "out", ".", "push", "(", "sjcl", ".", "bitArray", ".", "partial", "(", "8", "*", "(", "i", "&", "3", ")", ",", "tmp", ")", ")", ";", "}", "return", "out", ";", "}" ]
Convert from a UTF-8 string to a bitArray.
[ "Convert", "from", "a", "UTF", "-", "8", "string", "to", "a", "bitArray", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L516-L530
27,025
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (arr) { var out = "", i; for (i=0; i<arr.length; i++) { out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4); } return out.substr(0, sjcl.bitArray.bitLength(arr)/4);//.replace(/(.{8})/g, "$1 "); }
javascript
function (arr) { var out = "", i; for (i=0; i<arr.length; i++) { out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4); } return out.substr(0, sjcl.bitArray.bitLength(arr)/4);//.replace(/(.{8})/g, "$1 "); }
[ "function", "(", "arr", ")", "{", "var", "out", "=", "\"\"", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "arr", ".", "length", ";", "i", "++", ")", "{", "out", "+=", "(", "(", "arr", "[", "i", "]", "|", "0", ")", "+", "0xF00000000000", ")", ".", "toString", "(", "16", ")", ".", "substr", "(", "4", ")", ";", "}", "return", "out", ".", "substr", "(", "0", ",", "sjcl", ".", "bitArray", ".", "bitLength", "(", "arr", ")", "/", "4", ")", ";", "//.replace(/(.{8})/g, \"$1 \");", "}" ]
Convert from a bitArray to a hex string.
[ "Convert", "from", "a", "bitArray", "to", "a", "hex", "string", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L542-L548
27,026
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (str) { var i, out=[], len; str = str.replace(/\s|0x/g, ""); len = str.length; str = str + "00000000"; for (i=0; i<str.length; i+=8) { out.push(parseInt(str.substr(i,8),16)^0); } return sjcl.bitArray.clamp(out, len*4); }
javascript
function (str) { var i, out=[], len; str = str.replace(/\s|0x/g, ""); len = str.length; str = str + "00000000"; for (i=0; i<str.length; i+=8) { out.push(parseInt(str.substr(i,8),16)^0); } return sjcl.bitArray.clamp(out, len*4); }
[ "function", "(", "str", ")", "{", "var", "i", ",", "out", "=", "[", "]", ",", "len", ";", "str", "=", "str", ".", "replace", "(", "/", "\\s|0x", "/", "g", ",", "\"\"", ")", ";", "len", "=", "str", ".", "length", ";", "str", "=", "str", "+", "\"00000000\"", ";", "for", "(", "i", "=", "0", ";", "i", "<", "str", ".", "length", ";", "i", "+=", "8", ")", "{", "out", ".", "push", "(", "parseInt", "(", "str", ".", "substr", "(", "i", ",", "8", ")", ",", "16", ")", "^", "0", ")", ";", "}", "return", "sjcl", ".", "bitArray", ".", "clamp", "(", "out", ",", "len", "*", "4", ")", ";", "}" ]
Convert from a hex string to a bitArray.
[ "Convert", "from", "a", "hex", "string", "to", "a", "bitArray", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L550-L559
27,027
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (arr, _noEquals, _url) { var out = "", i, bits=0, c = sjcl.codec.base64._chars, ta=0, bl = sjcl.bitArray.bitLength(arr); if (_url) { c = c.substr(0,62) + '-_'; } for (i=0; out.length * 6 < bl; ) { out += c.charAt((ta ^ arr[i]>>>bits) >>> 26); if (bits < 6) { ta = arr[i] << (6-bits); bits += 26; i++; } else { ta <<= 6; bits -= 6; } } while ((out.length & 3) && !_noEquals) { out += "="; } return out; }
javascript
function (arr, _noEquals, _url) { var out = "", i, bits=0, c = sjcl.codec.base64._chars, ta=0, bl = sjcl.bitArray.bitLength(arr); if (_url) { c = c.substr(0,62) + '-_'; } for (i=0; out.length * 6 < bl; ) { out += c.charAt((ta ^ arr[i]>>>bits) >>> 26); if (bits < 6) { ta = arr[i] << (6-bits); bits += 26; i++; } else { ta <<= 6; bits -= 6; } } while ((out.length & 3) && !_noEquals) { out += "="; } return out; }
[ "function", "(", "arr", ",", "_noEquals", ",", "_url", ")", "{", "var", "out", "=", "\"\"", ",", "i", ",", "bits", "=", "0", ",", "c", "=", "sjcl", ".", "codec", ".", "base64", ".", "_chars", ",", "ta", "=", "0", ",", "bl", "=", "sjcl", ".", "bitArray", ".", "bitLength", "(", "arr", ")", ";", "if", "(", "_url", ")", "{", "c", "=", "c", ".", "substr", "(", "0", ",", "62", ")", "+", "'-_'", ";", "}", "for", "(", "i", "=", "0", ";", "out", ".", "length", "*", "6", "<", "bl", ";", ")", "{", "out", "+=", "c", ".", "charAt", "(", "(", "ta", "^", "arr", "[", "i", "]", ">>>", "bits", ")", ">>>", "26", ")", ";", "if", "(", "bits", "<", "6", ")", "{", "ta", "=", "arr", "[", "i", "]", "<<", "(", "6", "-", "bits", ")", ";", "bits", "+=", "26", ";", "i", "++", ";", "}", "else", "{", "ta", "<<=", "6", ";", "bits", "-=", "6", ";", "}", "}", "while", "(", "(", "out", ".", "length", "&", "3", ")", "&&", "!", "_noEquals", ")", "{", "out", "+=", "\"=\"", ";", "}", "return", "out", ";", "}" ]
Convert from a bitArray to a base64 string.
[ "Convert", "from", "a", "bitArray", "to", "a", "base64", "string", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L577-L595
27,028
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(str, _url) { str = str.replace(/\s|=/g,''); var out = [], i, bits=0, c = sjcl.codec.base64._chars, ta=0, x; if (_url) { c = c.substr(0,62) + '-_'; } for (i=0; i<str.length; i++) { x = c.indexOf(str.charAt(i)); if (x < 0) { throw new sjcl.exception.invalid("this isn't base64!"); } if (bits > 26) { bits -= 26; out.push(ta ^ x>>>bits); ta = x << (32-bits); } else { bits += 6; ta ^= x << (32-bits); } } if (bits&56) { out.push(sjcl.bitArray.partial(bits&56, ta, 1)); } return out; }
javascript
function(str, _url) { str = str.replace(/\s|=/g,''); var out = [], i, bits=0, c = sjcl.codec.base64._chars, ta=0, x; if (_url) { c = c.substr(0,62) + '-_'; } for (i=0; i<str.length; i++) { x = c.indexOf(str.charAt(i)); if (x < 0) { throw new sjcl.exception.invalid("this isn't base64!"); } if (bits > 26) { bits -= 26; out.push(ta ^ x>>>bits); ta = x << (32-bits); } else { bits += 6; ta ^= x << (32-bits); } } if (bits&56) { out.push(sjcl.bitArray.partial(bits&56, ta, 1)); } return out; }
[ "function", "(", "str", ",", "_url", ")", "{", "str", "=", "str", ".", "replace", "(", "/", "\\s|=", "/", "g", ",", "''", ")", ";", "var", "out", "=", "[", "]", ",", "i", ",", "bits", "=", "0", ",", "c", "=", "sjcl", ".", "codec", ".", "base64", ".", "_chars", ",", "ta", "=", "0", ",", "x", ";", "if", "(", "_url", ")", "{", "c", "=", "c", ".", "substr", "(", "0", ",", "62", ")", "+", "'-_'", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "str", ".", "length", ";", "i", "++", ")", "{", "x", "=", "c", ".", "indexOf", "(", "str", ".", "charAt", "(", "i", ")", ")", ";", "if", "(", "x", "<", "0", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "invalid", "(", "\"this isn't base64!\"", ")", ";", "}", "if", "(", "bits", ">", "26", ")", "{", "bits", "-=", "26", ";", "out", ".", "push", "(", "ta", "^", "x", ">>>", "bits", ")", ";", "ta", "=", "x", "<<", "(", "32", "-", "bits", ")", ";", "}", "else", "{", "bits", "+=", "6", ";", "ta", "^=", "x", "<<", "(", "32", "-", "bits", ")", ";", "}", "}", "if", "(", "bits", "&", "56", ")", "{", "out", ".", "push", "(", "sjcl", ".", "bitArray", ".", "partial", "(", "bits", "&", "56", ",", "ta", ",", "1", ")", ")", ";", "}", "return", "out", ";", "}" ]
Convert from a base64 string to a bitArray
[ "Convert", "from", "a", "base64", "string", "to", "a", "bitArray" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L598-L622
27,029
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (data) { if (typeof data === "string") { data = sjcl.codec.utf8String.toBits(data); } var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data), ol = this._length, nl = this._length = ol + sjcl.bitArray.bitLength(data); for (i = 512+ol & -512; i <= nl; i+= 512) { this._block(b.splice(0,16)); } return this; }
javascript
function (data) { if (typeof data === "string") { data = sjcl.codec.utf8String.toBits(data); } var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data), ol = this._length, nl = this._length = ol + sjcl.bitArray.bitLength(data); for (i = 512+ol & -512; i <= nl; i+= 512) { this._block(b.splice(0,16)); } return this; }
[ "function", "(", "data", ")", "{", "if", "(", "typeof", "data", "===", "\"string\"", ")", "{", "data", "=", "sjcl", ".", "codec", ".", "utf8String", ".", "toBits", "(", "data", ")", ";", "}", "var", "i", ",", "b", "=", "this", ".", "_buffer", "=", "sjcl", ".", "bitArray", ".", "concat", "(", "this", ".", "_buffer", ",", "data", ")", ",", "ol", "=", "this", ".", "_length", ",", "nl", "=", "this", ".", "_length", "=", "ol", "+", "sjcl", ".", "bitArray", ".", "bitLength", "(", "data", ")", ";", "for", "(", "i", "=", "512", "+", "ol", "&", "-", "512", ";", "i", "<=", "nl", ";", "i", "+=", "512", ")", "{", "this", ".", "_block", "(", "b", ".", "splice", "(", "0", ",", "16", ")", ")", ";", "}", "return", "this", ";", "}" ]
Input several words to the hash. @param {bitArray|String} data the data to hash. @return this
[ "Input", "several", "words", "to", "the", "hash", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L693-L704
27,030
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (words) { var i, tmp, a, b, w = words.slice(0), h = this._h, k = this._key, h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3], h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7]; /* Rationale for placement of |0 : * If a value can overflow is original 32 bits by a factor of more than a few * million (2^23 ish), there is a possibility that it might overflow the * 53-bit mantissa and lose precision. * * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that * propagates around the loop, and on the hash state h[]. I don't believe * that the clamps on h4 and on h0 are strictly necessary, but it's close * (for h4 anyway), and better safe than sorry. * * The clamps on h[] are necessary for the output to be correct even in the * common case and for short inputs. */ for (i=0; i<64; i++) { // load up the input word for this round if (i<16) { tmp = w[i]; } else { a = w[(i+1 ) & 15]; b = w[(i+14) & 15]; tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) + (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) + w[i&15] + w[(i+9) & 15]) | 0; } tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0; // shift register h7 = h6; h6 = h5; h5 = h4; h4 = h3 + tmp | 0; h3 = h2; h2 = h1; h1 = h0; h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1>>>2 ^ h1>>>13 ^ h1>>>22 ^ h1<<30 ^ h1<<19 ^ h1<<10)) | 0; } h[0] = h[0]+h0 | 0; h[1] = h[1]+h1 | 0; h[2] = h[2]+h2 | 0; h[3] = h[3]+h3 | 0; h[4] = h[4]+h4 | 0; h[5] = h[5]+h5 | 0; h[6] = h[6]+h6 | 0; h[7] = h[7]+h7 | 0; }
javascript
function (words) { var i, tmp, a, b, w = words.slice(0), h = this._h, k = this._key, h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3], h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7]; /* Rationale for placement of |0 : * If a value can overflow is original 32 bits by a factor of more than a few * million (2^23 ish), there is a possibility that it might overflow the * 53-bit mantissa and lose precision. * * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that * propagates around the loop, and on the hash state h[]. I don't believe * that the clamps on h4 and on h0 are strictly necessary, but it's close * (for h4 anyway), and better safe than sorry. * * The clamps on h[] are necessary for the output to be correct even in the * common case and for short inputs. */ for (i=0; i<64; i++) { // load up the input word for this round if (i<16) { tmp = w[i]; } else { a = w[(i+1 ) & 15]; b = w[(i+14) & 15]; tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) + (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) + w[i&15] + w[(i+9) & 15]) | 0; } tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0; // shift register h7 = h6; h6 = h5; h5 = h4; h4 = h3 + tmp | 0; h3 = h2; h2 = h1; h1 = h0; h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1>>>2 ^ h1>>>13 ^ h1>>>22 ^ h1<<30 ^ h1<<19 ^ h1<<10)) | 0; } h[0] = h[0]+h0 | 0; h[1] = h[1]+h1 | 0; h[2] = h[2]+h2 | 0; h[3] = h[3]+h3 | 0; h[4] = h[4]+h4 | 0; h[5] = h[5]+h5 | 0; h[6] = h[6]+h6 | 0; h[7] = h[7]+h7 | 0; }
[ "function", "(", "words", ")", "{", "var", "i", ",", "tmp", ",", "a", ",", "b", ",", "w", "=", "words", ".", "slice", "(", "0", ")", ",", "h", "=", "this", ".", "_h", ",", "k", "=", "this", ".", "_key", ",", "h0", "=", "h", "[", "0", "]", ",", "h1", "=", "h", "[", "1", "]", ",", "h2", "=", "h", "[", "2", "]", ",", "h3", "=", "h", "[", "3", "]", ",", "h4", "=", "h", "[", "4", "]", ",", "h5", "=", "h", "[", "5", "]", ",", "h6", "=", "h", "[", "6", "]", ",", "h7", "=", "h", "[", "7", "]", ";", "/* Rationale for placement of |0 :\n * If a value can overflow is original 32 bits by a factor of more than a few\n * million (2^23 ish), there is a possibility that it might overflow the\n * 53-bit mantissa and lose precision.\n *\n * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that\n * propagates around the loop, and on the hash state h[]. I don't believe\n * that the clamps on h4 and on h0 are strictly necessary, but it's close\n * (for h4 anyway), and better safe than sorry.\n *\n * The clamps on h[] are necessary for the output to be correct even in the\n * common case and for short inputs.\n */", "for", "(", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "{", "// load up the input word for this round", "if", "(", "i", "<", "16", ")", "{", "tmp", "=", "w", "[", "i", "]", ";", "}", "else", "{", "a", "=", "w", "[", "(", "i", "+", "1", ")", "&", "15", "]", ";", "b", "=", "w", "[", "(", "i", "+", "14", ")", "&", "15", "]", ";", "tmp", "=", "w", "[", "i", "&", "15", "]", "=", "(", "(", "a", ">>>", "7", "^", "a", ">>>", "18", "^", "a", ">>>", "3", "^", "a", "<<", "25", "^", "a", "<<", "14", ")", "+", "(", "b", ">>>", "17", "^", "b", ">>>", "19", "^", "b", ">>>", "10", "^", "b", "<<", "15", "^", "b", "<<", "13", ")", "+", "w", "[", "i", "&", "15", "]", "+", "w", "[", "(", "i", "+", "9", ")", "&", "15", "]", ")", "|", "0", ";", "}", "tmp", "=", "(", "tmp", "+", "h7", "+", "(", "h4", ">>>", "6", "^", "h4", ">>>", "11", "^", "h4", ">>>", "25", "^", "h4", "<<", "26", "^", "h4", "<<", "21", "^", "h4", "<<", "7", ")", "+", "(", "h6", "^", "h4", "&", "(", "h5", "^", "h6", ")", ")", "+", "k", "[", "i", "]", ")", ";", "// | 0;", "// shift register", "h7", "=", "h6", ";", "h6", "=", "h5", ";", "h5", "=", "h4", ";", "h4", "=", "h3", "+", "tmp", "|", "0", ";", "h3", "=", "h2", ";", "h2", "=", "h1", ";", "h1", "=", "h0", ";", "h0", "=", "(", "tmp", "+", "(", "(", "h1", "&", "h2", ")", "^", "(", "h3", "&", "(", "h1", "^", "h2", ")", ")", ")", "+", "(", "h1", ">>>", "2", "^", "h1", ">>>", "13", "^", "h1", ">>>", "22", "^", "h1", "<<", "30", "^", "h1", "<<", "19", "^", "h1", "<<", "10", ")", ")", "|", "0", ";", "}", "h", "[", "0", "]", "=", "h", "[", "0", "]", "+", "h0", "|", "0", ";", "h", "[", "1", "]", "=", "h", "[", "1", "]", "+", "h1", "|", "0", ";", "h", "[", "2", "]", "=", "h", "[", "2", "]", "+", "h2", "|", "0", ";", "h", "[", "3", "]", "=", "h", "[", "3", "]", "+", "h3", "|", "0", ";", "h", "[", "4", "]", "=", "h", "[", "4", "]", "+", "h4", "|", "0", ";", "h", "[", "5", "]", "=", "h", "[", "5", "]", "+", "h5", "|", "0", ";", "h", "[", "6", "]", "=", "h", "[", "6", "]", "+", "h6", "|", "0", ";", "h", "[", "7", "]", "=", "h", "[", "7", "]", "+", "h7", "|", "0", ";", "}" ]
Perform one cycle of SHA-256. @param {bitArray} words one block of words. @private
[ "Perform", "one", "cycle", "of", "SHA", "-", "256", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L790-L841
27,031
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(prf, plaintext, iv, adata, tlen) { var L, out = plaintext.slice(0), tag, w=sjcl.bitArray, ivl = w.bitLength(iv) / 8, ol = w.bitLength(out) / 8; tlen = tlen || 64; adata = adata || []; if (ivl < 7) { throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes"); } // compute the length of the length for (L=2; L<4 && ol >>> 8*L; L++) {} if (L < 15 - ivl) { L = 15-ivl; } iv = w.clamp(iv,8*(15-L)); // compute the tag tag = sjcl.mode.ccm._computeTag(prf, plaintext, iv, adata, tlen, L); // encrypt out = sjcl.mode.ccm._ctrMode(prf, out, iv, tag, tlen, L); return w.concat(out.data, out.tag); }
javascript
function(prf, plaintext, iv, adata, tlen) { var L, out = plaintext.slice(0), tag, w=sjcl.bitArray, ivl = w.bitLength(iv) / 8, ol = w.bitLength(out) / 8; tlen = tlen || 64; adata = adata || []; if (ivl < 7) { throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes"); } // compute the length of the length for (L=2; L<4 && ol >>> 8*L; L++) {} if (L < 15 - ivl) { L = 15-ivl; } iv = w.clamp(iv,8*(15-L)); // compute the tag tag = sjcl.mode.ccm._computeTag(prf, plaintext, iv, adata, tlen, L); // encrypt out = sjcl.mode.ccm._ctrMode(prf, out, iv, tag, tlen, L); return w.concat(out.data, out.tag); }
[ "function", "(", "prf", ",", "plaintext", ",", "iv", ",", "adata", ",", "tlen", ")", "{", "var", "L", ",", "out", "=", "plaintext", ".", "slice", "(", "0", ")", ",", "tag", ",", "w", "=", "sjcl", ".", "bitArray", ",", "ivl", "=", "w", ".", "bitLength", "(", "iv", ")", "/", "8", ",", "ol", "=", "w", ".", "bitLength", "(", "out", ")", "/", "8", ";", "tlen", "=", "tlen", "||", "64", ";", "adata", "=", "adata", "||", "[", "]", ";", "if", "(", "ivl", "<", "7", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "invalid", "(", "\"ccm: iv must be at least 7 bytes\"", ")", ";", "}", "// compute the length of the length", "for", "(", "L", "=", "2", ";", "L", "<", "4", "&&", "ol", ">>>", "8", "*", "L", ";", "L", "++", ")", "{", "}", "if", "(", "L", "<", "15", "-", "ivl", ")", "{", "L", "=", "15", "-", "ivl", ";", "}", "iv", "=", "w", ".", "clamp", "(", "iv", ",", "8", "*", "(", "15", "-", "L", ")", ")", ";", "// compute the tag", "tag", "=", "sjcl", ".", "mode", ".", "ccm", ".", "_computeTag", "(", "prf", ",", "plaintext", ",", "iv", ",", "adata", ",", "tlen", ",", "L", ")", ";", "// encrypt", "out", "=", "sjcl", ".", "mode", ".", "ccm", ".", "_ctrMode", "(", "prf", ",", "out", ",", "iv", ",", "tag", ",", "tlen", ",", "L", ")", ";", "return", "w", ".", "concat", "(", "out", ".", "data", ",", "out", ".", "tag", ")", ";", "}" ]
Encrypt in CCM mode. @static @param {Object} prf The pseudorandom function. It must have a block size of 16 bytes. @param {bitArray} plaintext The plaintext data. @param {bitArray} iv The initialization value. @param {bitArray} [adata=[]] The authenticated data. @param {Number} [tlen=64] the desired tag length, in bits. @return {bitArray} The encrypted data, an array of bytes.
[ "Encrypt", "in", "CCM", "mode", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L871-L892
27,032
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(prf, ciphertext, iv, adata, tlen) { tlen = tlen || 64; adata = adata || []; var L, w=sjcl.bitArray, ivl = w.bitLength(iv) / 8, ol = w.bitLength(ciphertext), out = w.clamp(ciphertext, ol - tlen), tag = w.bitSlice(ciphertext, ol - tlen), tag2; ol = (ol - tlen) / 8; if (ivl < 7) { throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes"); } // compute the length of the length for (L=2; L<4 && ol >>> 8*L; L++) {} if (L < 15 - ivl) { L = 15-ivl; } iv = w.clamp(iv,8*(15-L)); // decrypt out = sjcl.mode.ccm._ctrMode(prf, out, iv, tag, tlen, L); // check the tag tag2 = sjcl.mode.ccm._computeTag(prf, out.data, iv, adata, tlen, L); if (!w.equal(out.tag, tag2)) { throw new sjcl.exception.corrupt("ccm: tag doesn't match"); } return out.data; }
javascript
function(prf, ciphertext, iv, adata, tlen) { tlen = tlen || 64; adata = adata || []; var L, w=sjcl.bitArray, ivl = w.bitLength(iv) / 8, ol = w.bitLength(ciphertext), out = w.clamp(ciphertext, ol - tlen), tag = w.bitSlice(ciphertext, ol - tlen), tag2; ol = (ol - tlen) / 8; if (ivl < 7) { throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes"); } // compute the length of the length for (L=2; L<4 && ol >>> 8*L; L++) {} if (L < 15 - ivl) { L = 15-ivl; } iv = w.clamp(iv,8*(15-L)); // decrypt out = sjcl.mode.ccm._ctrMode(prf, out, iv, tag, tlen, L); // check the tag tag2 = sjcl.mode.ccm._computeTag(prf, out.data, iv, adata, tlen, L); if (!w.equal(out.tag, tag2)) { throw new sjcl.exception.corrupt("ccm: tag doesn't match"); } return out.data; }
[ "function", "(", "prf", ",", "ciphertext", ",", "iv", ",", "adata", ",", "tlen", ")", "{", "tlen", "=", "tlen", "||", "64", ";", "adata", "=", "adata", "||", "[", "]", ";", "var", "L", ",", "w", "=", "sjcl", ".", "bitArray", ",", "ivl", "=", "w", ".", "bitLength", "(", "iv", ")", "/", "8", ",", "ol", "=", "w", ".", "bitLength", "(", "ciphertext", ")", ",", "out", "=", "w", ".", "clamp", "(", "ciphertext", ",", "ol", "-", "tlen", ")", ",", "tag", "=", "w", ".", "bitSlice", "(", "ciphertext", ",", "ol", "-", "tlen", ")", ",", "tag2", ";", "ol", "=", "(", "ol", "-", "tlen", ")", "/", "8", ";", "if", "(", "ivl", "<", "7", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "invalid", "(", "\"ccm: iv must be at least 7 bytes\"", ")", ";", "}", "// compute the length of the length", "for", "(", "L", "=", "2", ";", "L", "<", "4", "&&", "ol", ">>>", "8", "*", "L", ";", "L", "++", ")", "{", "}", "if", "(", "L", "<", "15", "-", "ivl", ")", "{", "L", "=", "15", "-", "ivl", ";", "}", "iv", "=", "w", ".", "clamp", "(", "iv", ",", "8", "*", "(", "15", "-", "L", ")", ")", ";", "// decrypt", "out", "=", "sjcl", ".", "mode", ".", "ccm", ".", "_ctrMode", "(", "prf", ",", "out", ",", "iv", ",", "tag", ",", "tlen", ",", "L", ")", ";", "// check the tag", "tag2", "=", "sjcl", ".", "mode", ".", "ccm", ".", "_computeTag", "(", "prf", ",", "out", ".", "data", ",", "iv", ",", "adata", ",", "tlen", ",", "L", ")", ";", "if", "(", "!", "w", ".", "equal", "(", "out", ".", "tag", ",", "tag2", ")", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "corrupt", "(", "\"ccm: tag doesn't match\"", ")", ";", "}", "return", "out", ".", "data", ";", "}" ]
Decrypt in CCM mode. @static @param {Object} prf The pseudorandom function. It must have a block size of 16 bytes. @param {bitArray} ciphertext The ciphertext data. @param {bitArray} iv The initialization value. @param {bitArray} [[]] adata The authenticated data. @param {Number} [64] tlen the desired tag length, in bits. @return {bitArray} The decrypted data.
[ "Decrypt", "in", "CCM", "mode", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L903-L935
27,033
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(prf, data, iv, tag, tlen, L) { var enc, i, w=sjcl.bitArray, xor = w._xor4, ctr, l = data.length, bl=w.bitLength(data); // start the ctr ctr = w.concat([w.partial(8,L-1)],iv).concat([0,0,0]).slice(0,4); // en/decrypt the tag tag = w.bitSlice(xor(tag,prf.encrypt(ctr)), 0, tlen); // en/decrypt the data if (!l) { return {tag:tag, data:[]}; } for (i=0; i<l; i+=4) { ctr[3]++; enc = prf.encrypt(ctr); data[i] ^= enc[0]; data[i+1] ^= enc[1]; data[i+2] ^= enc[2]; data[i+3] ^= enc[3]; } return { tag:tag, data:w.clamp(data,bl) }; }
javascript
function(prf, data, iv, tag, tlen, L) { var enc, i, w=sjcl.bitArray, xor = w._xor4, ctr, l = data.length, bl=w.bitLength(data); // start the ctr ctr = w.concat([w.partial(8,L-1)],iv).concat([0,0,0]).slice(0,4); // en/decrypt the tag tag = w.bitSlice(xor(tag,prf.encrypt(ctr)), 0, tlen); // en/decrypt the data if (!l) { return {tag:tag, data:[]}; } for (i=0; i<l; i+=4) { ctr[3]++; enc = prf.encrypt(ctr); data[i] ^= enc[0]; data[i+1] ^= enc[1]; data[i+2] ^= enc[2]; data[i+3] ^= enc[3]; } return { tag:tag, data:w.clamp(data,bl) }; }
[ "function", "(", "prf", ",", "data", ",", "iv", ",", "tag", ",", "tlen", ",", "L", ")", "{", "var", "enc", ",", "i", ",", "w", "=", "sjcl", ".", "bitArray", ",", "xor", "=", "w", ".", "_xor4", ",", "ctr", ",", "l", "=", "data", ".", "length", ",", "bl", "=", "w", ".", "bitLength", "(", "data", ")", ";", "// start the ctr", "ctr", "=", "w", ".", "concat", "(", "[", "w", ".", "partial", "(", "8", ",", "L", "-", "1", ")", "]", ",", "iv", ")", ".", "concat", "(", "[", "0", ",", "0", ",", "0", "]", ")", ".", "slice", "(", "0", ",", "4", ")", ";", "// en/decrypt the tag", "tag", "=", "w", ".", "bitSlice", "(", "xor", "(", "tag", ",", "prf", ".", "encrypt", "(", "ctr", ")", ")", ",", "0", ",", "tlen", ")", ";", "// en/decrypt the data", "if", "(", "!", "l", ")", "{", "return", "{", "tag", ":", "tag", ",", "data", ":", "[", "]", "}", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "l", ";", "i", "+=", "4", ")", "{", "ctr", "[", "3", "]", "++", ";", "enc", "=", "prf", ".", "encrypt", "(", "ctr", ")", ";", "data", "[", "i", "]", "^=", "enc", "[", "0", "]", ";", "data", "[", "i", "+", "1", "]", "^=", "enc", "[", "1", "]", ";", "data", "[", "i", "+", "2", "]", "^=", "enc", "[", "2", "]", ";", "data", "[", "i", "+", "3", "]", "^=", "enc", "[", "3", "]", ";", "}", "return", "{", "tag", ":", "tag", ",", "data", ":", "w", ".", "clamp", "(", "data", ",", "bl", ")", "}", ";", "}" ]
CCM CTR mode. Encrypt or decrypt data and tag with the prf in CCM-style CTR mode. May mutate its arguments. @param {Object} prf The PRF. @param {bitArray} data The data to be encrypted or decrypted. @param {bitArray} iv The initialization vector. @param {bitArray} tag The authentication tag. @param {Number} tlen The length of th etag, in bits. @param {Number} L The CCM L value. @return {Object} An object with data and tag, the en/decryption of data and tag values. @private
[ "CCM", "CTR", "mode", ".", "Encrypt", "or", "decrypt", "data", "and", "tag", "with", "the", "prf", "in", "CCM", "-", "style", "CTR", "mode", ".", "May", "mutate", "its", "arguments", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1007-L1028
27,034
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(prp, plaintext, iv, adata, tlen, premac) { if (sjcl.bitArray.bitLength(iv) !== 128) { throw new sjcl.exception.invalid("ocb iv must be 128 bits"); } var i, times2 = sjcl.mode.ocb2._times2, w = sjcl.bitArray, xor = w._xor4, checksum = [0,0,0,0], delta = times2(prp.encrypt(iv)), bi, bl, output = [], pad; adata = adata || []; tlen = tlen || 64; for (i=0; i+4 < plaintext.length; i+=4) { /* Encrypt a non-final block */ bi = plaintext.slice(i,i+4); checksum = xor(checksum, bi); output = output.concat(xor(delta,prp.encrypt(xor(delta, bi)))); delta = times2(delta); } /* Chop out the final block */ bi = plaintext.slice(i); bl = w.bitLength(bi); pad = prp.encrypt(xor(delta,[0,0,0,bl])); bi = w.clamp(xor(bi.concat([0,0,0]),pad), bl); /* Checksum the final block, and finalize the checksum */ checksum = xor(checksum,xor(bi.concat([0,0,0]),pad)); checksum = prp.encrypt(xor(checksum,xor(delta,times2(delta)))); /* MAC the header */ if (adata.length) { checksum = xor(checksum, premac ? adata : sjcl.mode.ocb2.pmac(prp, adata)); } return output.concat(w.concat(bi, w.clamp(checksum, tlen))); }
javascript
function(prp, plaintext, iv, adata, tlen, premac) { if (sjcl.bitArray.bitLength(iv) !== 128) { throw new sjcl.exception.invalid("ocb iv must be 128 bits"); } var i, times2 = sjcl.mode.ocb2._times2, w = sjcl.bitArray, xor = w._xor4, checksum = [0,0,0,0], delta = times2(prp.encrypt(iv)), bi, bl, output = [], pad; adata = adata || []; tlen = tlen || 64; for (i=0; i+4 < plaintext.length; i+=4) { /* Encrypt a non-final block */ bi = plaintext.slice(i,i+4); checksum = xor(checksum, bi); output = output.concat(xor(delta,prp.encrypt(xor(delta, bi)))); delta = times2(delta); } /* Chop out the final block */ bi = plaintext.slice(i); bl = w.bitLength(bi); pad = prp.encrypt(xor(delta,[0,0,0,bl])); bi = w.clamp(xor(bi.concat([0,0,0]),pad), bl); /* Checksum the final block, and finalize the checksum */ checksum = xor(checksum,xor(bi.concat([0,0,0]),pad)); checksum = prp.encrypt(xor(checksum,xor(delta,times2(delta)))); /* MAC the header */ if (adata.length) { checksum = xor(checksum, premac ? adata : sjcl.mode.ocb2.pmac(prp, adata)); } return output.concat(w.concat(bi, w.clamp(checksum, tlen))); }
[ "function", "(", "prp", ",", "plaintext", ",", "iv", ",", "adata", ",", "tlen", ",", "premac", ")", "{", "if", "(", "sjcl", ".", "bitArray", ".", "bitLength", "(", "iv", ")", "!==", "128", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "invalid", "(", "\"ocb iv must be 128 bits\"", ")", ";", "}", "var", "i", ",", "times2", "=", "sjcl", ".", "mode", ".", "ocb2", ".", "_times2", ",", "w", "=", "sjcl", ".", "bitArray", ",", "xor", "=", "w", ".", "_xor4", ",", "checksum", "=", "[", "0", ",", "0", ",", "0", ",", "0", "]", ",", "delta", "=", "times2", "(", "prp", ".", "encrypt", "(", "iv", ")", ")", ",", "bi", ",", "bl", ",", "output", "=", "[", "]", ",", "pad", ";", "adata", "=", "adata", "||", "[", "]", ";", "tlen", "=", "tlen", "||", "64", ";", "for", "(", "i", "=", "0", ";", "i", "+", "4", "<", "plaintext", ".", "length", ";", "i", "+=", "4", ")", "{", "/* Encrypt a non-final block */", "bi", "=", "plaintext", ".", "slice", "(", "i", ",", "i", "+", "4", ")", ";", "checksum", "=", "xor", "(", "checksum", ",", "bi", ")", ";", "output", "=", "output", ".", "concat", "(", "xor", "(", "delta", ",", "prp", ".", "encrypt", "(", "xor", "(", "delta", ",", "bi", ")", ")", ")", ")", ";", "delta", "=", "times2", "(", "delta", ")", ";", "}", "/* Chop out the final block */", "bi", "=", "plaintext", ".", "slice", "(", "i", ")", ";", "bl", "=", "w", ".", "bitLength", "(", "bi", ")", ";", "pad", "=", "prp", ".", "encrypt", "(", "xor", "(", "delta", ",", "[", "0", ",", "0", ",", "0", ",", "bl", "]", ")", ")", ";", "bi", "=", "w", ".", "clamp", "(", "xor", "(", "bi", ".", "concat", "(", "[", "0", ",", "0", ",", "0", "]", ")", ",", "pad", ")", ",", "bl", ")", ";", "/* Checksum the final block, and finalize the checksum */", "checksum", "=", "xor", "(", "checksum", ",", "xor", "(", "bi", ".", "concat", "(", "[", "0", ",", "0", ",", "0", "]", ")", ",", "pad", ")", ")", ";", "checksum", "=", "prp", ".", "encrypt", "(", "xor", "(", "checksum", ",", "xor", "(", "delta", ",", "times2", "(", "delta", ")", ")", ")", ")", ";", "/* MAC the header */", "if", "(", "adata", ".", "length", ")", "{", "checksum", "=", "xor", "(", "checksum", ",", "premac", "?", "adata", ":", "sjcl", ".", "mode", ".", "ocb2", ".", "pmac", "(", "prp", ",", "adata", ")", ")", ";", "}", "return", "output", ".", "concat", "(", "w", ".", "concat", "(", "bi", ",", "w", ".", "clamp", "(", "checksum", ",", "tlen", ")", ")", ")", ";", "}" ]
Encrypt in OCB mode, version 2.0. @param {Object} prp The block cipher. It must have a block size of 16 bytes. @param {bitArray} plaintext The plaintext data. @param {bitArray} iv The initialization value. @param {bitArray} [adata=[]] The authenticated data. @param {Number} [tlen=64] the desired tag length, in bits. @param [false] premac 1 if the authentication data is pre-macced with PMAC. @return The encrypted data, an array of bytes. @throws {sjcl.exception.invalid} if the IV isn't exactly 128 bits.
[ "Encrypt", "in", "OCB", "mode", "version", "2", ".", "0", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1061-L1102
27,035
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(prp, adata) { var i, times2 = sjcl.mode.ocb2._times2, w = sjcl.bitArray, xor = w._xor4, checksum = [0,0,0,0], delta = prp.encrypt([0,0,0,0]), bi; delta = xor(delta,times2(times2(delta))); for (i=0; i+4<adata.length; i+=4) { delta = times2(delta); checksum = xor(checksum, prp.encrypt(xor(delta, adata.slice(i,i+4)))); } bi = adata.slice(i); if (w.bitLength(bi) < 128) { delta = xor(delta,times2(delta)); bi = w.concat(bi,[0x80000000|0,0,0,0]); } checksum = xor(checksum, bi); return prp.encrypt(xor(times2(xor(delta,times2(delta))), checksum)); }
javascript
function(prp, adata) { var i, times2 = sjcl.mode.ocb2._times2, w = sjcl.bitArray, xor = w._xor4, checksum = [0,0,0,0], delta = prp.encrypt([0,0,0,0]), bi; delta = xor(delta,times2(times2(delta))); for (i=0; i+4<adata.length; i+=4) { delta = times2(delta); checksum = xor(checksum, prp.encrypt(xor(delta, adata.slice(i,i+4)))); } bi = adata.slice(i); if (w.bitLength(bi) < 128) { delta = xor(delta,times2(delta)); bi = w.concat(bi,[0x80000000|0,0,0,0]); } checksum = xor(checksum, bi); return prp.encrypt(xor(times2(xor(delta,times2(delta))), checksum)); }
[ "function", "(", "prp", ",", "adata", ")", "{", "var", "i", ",", "times2", "=", "sjcl", ".", "mode", ".", "ocb2", ".", "_times2", ",", "w", "=", "sjcl", ".", "bitArray", ",", "xor", "=", "w", ".", "_xor4", ",", "checksum", "=", "[", "0", ",", "0", ",", "0", ",", "0", "]", ",", "delta", "=", "prp", ".", "encrypt", "(", "[", "0", ",", "0", ",", "0", ",", "0", "]", ")", ",", "bi", ";", "delta", "=", "xor", "(", "delta", ",", "times2", "(", "times2", "(", "delta", ")", ")", ")", ";", "for", "(", "i", "=", "0", ";", "i", "+", "4", "<", "adata", ".", "length", ";", "i", "+=", "4", ")", "{", "delta", "=", "times2", "(", "delta", ")", ";", "checksum", "=", "xor", "(", "checksum", ",", "prp", ".", "encrypt", "(", "xor", "(", "delta", ",", "adata", ".", "slice", "(", "i", ",", "i", "+", "4", ")", ")", ")", ")", ";", "}", "bi", "=", "adata", ".", "slice", "(", "i", ")", ";", "if", "(", "w", ".", "bitLength", "(", "bi", ")", "<", "128", ")", "{", "delta", "=", "xor", "(", "delta", ",", "times2", "(", "delta", ")", ")", ";", "bi", "=", "w", ".", "concat", "(", "bi", ",", "[", "0x80000000", "|", "0", ",", "0", ",", "0", ",", "0", "]", ")", ";", "}", "checksum", "=", "xor", "(", "checksum", ",", "bi", ")", ";", "return", "prp", ".", "encrypt", "(", "xor", "(", "times2", "(", "xor", "(", "delta", ",", "times2", "(", "delta", ")", ")", ")", ",", "checksum", ")", ")", ";", "}" ]
PMAC authentication for OCB associated data. @param {Object} prp The block cipher. It must have a block size of 16 bytes. @param {bitArray} adata The authenticated data.
[ "PMAC", "authentication", "for", "OCB", "associated", "data", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1166-L1189
27,036
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (prf, plaintext, iv, adata, tlen) { var out, data = plaintext.slice(0), w=sjcl.bitArray; tlen = tlen || 128; adata = adata || []; // encrypt and tag out = sjcl.mode.gcm._ctrMode(true, prf, data, adata, iv, tlen); return w.concat(out.data, out.tag); }
javascript
function (prf, plaintext, iv, adata, tlen) { var out, data = plaintext.slice(0), w=sjcl.bitArray; tlen = tlen || 128; adata = adata || []; // encrypt and tag out = sjcl.mode.gcm._ctrMode(true, prf, data, adata, iv, tlen); return w.concat(out.data, out.tag); }
[ "function", "(", "prf", ",", "plaintext", ",", "iv", ",", "adata", ",", "tlen", ")", "{", "var", "out", ",", "data", "=", "plaintext", ".", "slice", "(", "0", ")", ",", "w", "=", "sjcl", ".", "bitArray", ";", "tlen", "=", "tlen", "||", "128", ";", "adata", "=", "adata", "||", "[", "]", ";", "// encrypt and tag", "out", "=", "sjcl", ".", "mode", ".", "gcm", ".", "_ctrMode", "(", "true", ",", "prf", ",", "data", ",", "adata", ",", "iv", ",", "tlen", ")", ";", "return", "w", ".", "concat", "(", "out", ".", "data", ",", "out", ".", "tag", ")", ";", "}" ]
Encrypt in GCM mode. @static @param {Object} prf The pseudorandom function. It must have a block size of 16 bytes. @param {bitArray} plaintext The plaintext data. @param {bitArray} iv The initialization value. @param {bitArray} [adata=[]] The authenticated data. @param {Number} [tlen=128] The desired tag length, in bits. @return {bitArray} The encrypted data, an array of bytes.
[ "Encrypt", "in", "GCM", "mode", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1222-L1231
27,037
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (prf, ciphertext, iv, adata, tlen) { var out, data = ciphertext.slice(0), tag, w=sjcl.bitArray, l=w.bitLength(data); tlen = tlen || 128; adata = adata || []; // Slice tag out of data if (tlen <= l) { tag = w.bitSlice(data, l-tlen); data = w.bitSlice(data, 0, l-tlen); } else { tag = data; data = []; } // decrypt and tag out = sjcl.mode.gcm._ctrMode(false, prf, data, adata, iv, tlen); if (!w.equal(out.tag, tag)) { throw new sjcl.exception.corrupt("gcm: tag doesn't match"); } return out.data; }
javascript
function (prf, ciphertext, iv, adata, tlen) { var out, data = ciphertext.slice(0), tag, w=sjcl.bitArray, l=w.bitLength(data); tlen = tlen || 128; adata = adata || []; // Slice tag out of data if (tlen <= l) { tag = w.bitSlice(data, l-tlen); data = w.bitSlice(data, 0, l-tlen); } else { tag = data; data = []; } // decrypt and tag out = sjcl.mode.gcm._ctrMode(false, prf, data, adata, iv, tlen); if (!w.equal(out.tag, tag)) { throw new sjcl.exception.corrupt("gcm: tag doesn't match"); } return out.data; }
[ "function", "(", "prf", ",", "ciphertext", ",", "iv", ",", "adata", ",", "tlen", ")", "{", "var", "out", ",", "data", "=", "ciphertext", ".", "slice", "(", "0", ")", ",", "tag", ",", "w", "=", "sjcl", ".", "bitArray", ",", "l", "=", "w", ".", "bitLength", "(", "data", ")", ";", "tlen", "=", "tlen", "||", "128", ";", "adata", "=", "adata", "||", "[", "]", ";", "// Slice tag out of data", "if", "(", "tlen", "<=", "l", ")", "{", "tag", "=", "w", ".", "bitSlice", "(", "data", ",", "l", "-", "tlen", ")", ";", "data", "=", "w", ".", "bitSlice", "(", "data", ",", "0", ",", "l", "-", "tlen", ")", ";", "}", "else", "{", "tag", "=", "data", ";", "data", "=", "[", "]", ";", "}", "// decrypt and tag", "out", "=", "sjcl", ".", "mode", ".", "gcm", ".", "_ctrMode", "(", "false", ",", "prf", ",", "data", ",", "adata", ",", "iv", ",", "tlen", ")", ";", "if", "(", "!", "w", ".", "equal", "(", "out", ".", "tag", ",", "tag", ")", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "corrupt", "(", "\"gcm: tag doesn't match\"", ")", ";", "}", "return", "out", ".", "data", ";", "}" ]
Decrypt in GCM mode. @static @param {Object} prf The pseudorandom function. It must have a block size of 16 bytes. @param {bitArray} ciphertext The ciphertext data. @param {bitArray} iv The initialization value. @param {bitArray} [adata=[]] The authenticated data. @param {Number} [tlen=128] The desired tag length, in bits. @return {bitArray} The decrypted data.
[ "Decrypt", "in", "GCM", "mode", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1242-L1263
27,038
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function(encrypt, prf, data, adata, iv, tlen) { var H, J0, S0, enc, i, ctr, tag, last, l, bl, abl, ivbl, w=sjcl.bitArray; // Calculate data lengths l = data.length; bl = w.bitLength(data); abl = w.bitLength(adata); ivbl = w.bitLength(iv); // Calculate the parameters H = prf.encrypt([0,0,0,0]); if (ivbl === 96) { J0 = iv.slice(0); J0 = w.concat(J0, [1]); } else { J0 = sjcl.mode.gcm._ghash(H, [0,0,0,0], iv); J0 = sjcl.mode.gcm._ghash(H, J0, [0,0,Math.floor(ivbl/0x100000000),ivbl&0xffffffff]); } S0 = sjcl.mode.gcm._ghash(H, [0,0,0,0], adata); // Initialize ctr and tag ctr = J0.slice(0); tag = S0.slice(0); // If decrypting, calculate hash if (!encrypt) { tag = sjcl.mode.gcm._ghash(H, S0, data); } // Encrypt all the data for (i=0; i<l; i+=4) { ctr[3]++; enc = prf.encrypt(ctr); data[i] ^= enc[0]; data[i+1] ^= enc[1]; data[i+2] ^= enc[2]; data[i+3] ^= enc[3]; } data = w.clamp(data, bl); // If encrypting, calculate hash if (encrypt) { tag = sjcl.mode.gcm._ghash(H, S0, data); } // Calculate last block from bit lengths, ugly because bitwise operations are 32-bit last = [ Math.floor(abl/0x100000000), abl&0xffffffff, Math.floor(bl/0x100000000), bl&0xffffffff ]; // Calculate the final tag block tag = sjcl.mode.gcm._ghash(H, tag, last); enc = prf.encrypt(J0); tag[0] ^= enc[0]; tag[1] ^= enc[1]; tag[2] ^= enc[2]; tag[3] ^= enc[3]; return { tag:w.bitSlice(tag, 0, tlen), data:data }; }
javascript
function(encrypt, prf, data, adata, iv, tlen) { var H, J0, S0, enc, i, ctr, tag, last, l, bl, abl, ivbl, w=sjcl.bitArray; // Calculate data lengths l = data.length; bl = w.bitLength(data); abl = w.bitLength(adata); ivbl = w.bitLength(iv); // Calculate the parameters H = prf.encrypt([0,0,0,0]); if (ivbl === 96) { J0 = iv.slice(0); J0 = w.concat(J0, [1]); } else { J0 = sjcl.mode.gcm._ghash(H, [0,0,0,0], iv); J0 = sjcl.mode.gcm._ghash(H, J0, [0,0,Math.floor(ivbl/0x100000000),ivbl&0xffffffff]); } S0 = sjcl.mode.gcm._ghash(H, [0,0,0,0], adata); // Initialize ctr and tag ctr = J0.slice(0); tag = S0.slice(0); // If decrypting, calculate hash if (!encrypt) { tag = sjcl.mode.gcm._ghash(H, S0, data); } // Encrypt all the data for (i=0; i<l; i+=4) { ctr[3]++; enc = prf.encrypt(ctr); data[i] ^= enc[0]; data[i+1] ^= enc[1]; data[i+2] ^= enc[2]; data[i+3] ^= enc[3]; } data = w.clamp(data, bl); // If encrypting, calculate hash if (encrypt) { tag = sjcl.mode.gcm._ghash(H, S0, data); } // Calculate last block from bit lengths, ugly because bitwise operations are 32-bit last = [ Math.floor(abl/0x100000000), abl&0xffffffff, Math.floor(bl/0x100000000), bl&0xffffffff ]; // Calculate the final tag block tag = sjcl.mode.gcm._ghash(H, tag, last); enc = prf.encrypt(J0); tag[0] ^= enc[0]; tag[1] ^= enc[1]; tag[2] ^= enc[2]; tag[3] ^= enc[3]; return { tag:w.bitSlice(tag, 0, tlen), data:data }; }
[ "function", "(", "encrypt", ",", "prf", ",", "data", ",", "adata", ",", "iv", ",", "tlen", ")", "{", "var", "H", ",", "J0", ",", "S0", ",", "enc", ",", "i", ",", "ctr", ",", "tag", ",", "last", ",", "l", ",", "bl", ",", "abl", ",", "ivbl", ",", "w", "=", "sjcl", ".", "bitArray", ";", "// Calculate data lengths", "l", "=", "data", ".", "length", ";", "bl", "=", "w", ".", "bitLength", "(", "data", ")", ";", "abl", "=", "w", ".", "bitLength", "(", "adata", ")", ";", "ivbl", "=", "w", ".", "bitLength", "(", "iv", ")", ";", "// Calculate the parameters", "H", "=", "prf", ".", "encrypt", "(", "[", "0", ",", "0", ",", "0", ",", "0", "]", ")", ";", "if", "(", "ivbl", "===", "96", ")", "{", "J0", "=", "iv", ".", "slice", "(", "0", ")", ";", "J0", "=", "w", ".", "concat", "(", "J0", ",", "[", "1", "]", ")", ";", "}", "else", "{", "J0", "=", "sjcl", ".", "mode", ".", "gcm", ".", "_ghash", "(", "H", ",", "[", "0", ",", "0", ",", "0", ",", "0", "]", ",", "iv", ")", ";", "J0", "=", "sjcl", ".", "mode", ".", "gcm", ".", "_ghash", "(", "H", ",", "J0", ",", "[", "0", ",", "0", ",", "Math", ".", "floor", "(", "ivbl", "/", "0x100000000", ")", ",", "ivbl", "&", "0xffffffff", "]", ")", ";", "}", "S0", "=", "sjcl", ".", "mode", ".", "gcm", ".", "_ghash", "(", "H", ",", "[", "0", ",", "0", ",", "0", ",", "0", "]", ",", "adata", ")", ";", "// Initialize ctr and tag", "ctr", "=", "J0", ".", "slice", "(", "0", ")", ";", "tag", "=", "S0", ".", "slice", "(", "0", ")", ";", "// If decrypting, calculate hash", "if", "(", "!", "encrypt", ")", "{", "tag", "=", "sjcl", ".", "mode", ".", "gcm", ".", "_ghash", "(", "H", ",", "S0", ",", "data", ")", ";", "}", "// Encrypt all the data", "for", "(", "i", "=", "0", ";", "i", "<", "l", ";", "i", "+=", "4", ")", "{", "ctr", "[", "3", "]", "++", ";", "enc", "=", "prf", ".", "encrypt", "(", "ctr", ")", ";", "data", "[", "i", "]", "^=", "enc", "[", "0", "]", ";", "data", "[", "i", "+", "1", "]", "^=", "enc", "[", "1", "]", ";", "data", "[", "i", "+", "2", "]", "^=", "enc", "[", "2", "]", ";", "data", "[", "i", "+", "3", "]", "^=", "enc", "[", "3", "]", ";", "}", "data", "=", "w", ".", "clamp", "(", "data", ",", "bl", ")", ";", "// If encrypting, calculate hash", "if", "(", "encrypt", ")", "{", "tag", "=", "sjcl", ".", "mode", ".", "gcm", ".", "_ghash", "(", "H", ",", "S0", ",", "data", ")", ";", "}", "// Calculate last block from bit lengths, ugly because bitwise operations are 32-bit", "last", "=", "[", "Math", ".", "floor", "(", "abl", "/", "0x100000000", ")", ",", "abl", "&", "0xffffffff", ",", "Math", ".", "floor", "(", "bl", "/", "0x100000000", ")", ",", "bl", "&", "0xffffffff", "]", ";", "// Calculate the final tag block", "tag", "=", "sjcl", ".", "mode", ".", "gcm", ".", "_ghash", "(", "H", ",", "tag", ",", "last", ")", ";", "enc", "=", "prf", ".", "encrypt", "(", "J0", ")", ";", "tag", "[", "0", "]", "^=", "enc", "[", "0", "]", ";", "tag", "[", "1", "]", "^=", "enc", "[", "1", "]", ";", "tag", "[", "2", "]", "^=", "enc", "[", "2", "]", ";", "tag", "[", "3", "]", "^=", "enc", "[", "3", "]", ";", "return", "{", "tag", ":", "w", ".", "bitSlice", "(", "tag", ",", "0", ",", "tlen", ")", ",", "data", ":", "data", "}", ";", "}" ]
GCM CTR mode. Encrypt or decrypt data and tag with the prf in GCM-style CTR mode. @param {Boolean} encrypt True if encrypt, false if decrypt. @param {Object} prf The PRF. @param {bitArray} data The data to be encrypted or decrypted. @param {bitArray} iv The initialization vector. @param {bitArray} adata The associated data to be tagged. @param {Number} tlen The length of the tag, in bits.
[ "GCM", "CTR", "mode", ".", "Encrypt", "or", "decrypt", "data", "and", "tag", "with", "the", "prf", "in", "GCM", "-", "style", "CTR", "mode", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1322-L1382
27,039
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (paranoia) { var entropyRequired = this._PARANOIA_LEVELS[ (paranoia !== undefined) ? paranoia : this._defaultParanoia ]; if (this._strength && this._strength >= entropyRequired) { return (this._poolEntropy[0] > this._BITS_PER_RESEED && (new Date()).valueOf() > this._nextReseed) ? this._REQUIRES_RESEED | this._READY : this._READY; } else { return (this._poolStrength >= entropyRequired) ? this._REQUIRES_RESEED | this._NOT_READY : this._NOT_READY; } }
javascript
function (paranoia) { var entropyRequired = this._PARANOIA_LEVELS[ (paranoia !== undefined) ? paranoia : this._defaultParanoia ]; if (this._strength && this._strength >= entropyRequired) { return (this._poolEntropy[0] > this._BITS_PER_RESEED && (new Date()).valueOf() > this._nextReseed) ? this._REQUIRES_RESEED | this._READY : this._READY; } else { return (this._poolStrength >= entropyRequired) ? this._REQUIRES_RESEED | this._NOT_READY : this._NOT_READY; } }
[ "function", "(", "paranoia", ")", "{", "var", "entropyRequired", "=", "this", ".", "_PARANOIA_LEVELS", "[", "(", "paranoia", "!==", "undefined", ")", "?", "paranoia", ":", "this", ".", "_defaultParanoia", "]", ";", "if", "(", "this", ".", "_strength", "&&", "this", ".", "_strength", ">=", "entropyRequired", ")", "{", "return", "(", "this", ".", "_poolEntropy", "[", "0", "]", ">", "this", ".", "_BITS_PER_RESEED", "&&", "(", "new", "Date", "(", ")", ")", ".", "valueOf", "(", ")", ">", "this", ".", "_nextReseed", ")", "?", "this", ".", "_REQUIRES_RESEED", "|", "this", ".", "_READY", ":", "this", ".", "_READY", ";", "}", "else", "{", "return", "(", "this", ".", "_poolStrength", ">=", "entropyRequired", ")", "?", "this", ".", "_REQUIRES_RESEED", "|", "this", ".", "_NOT_READY", ":", "this", ".", "_NOT_READY", ";", "}", "}" ]
Is the generator ready?
[ "Is", "the", "generator", "ready?" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1713-L1725
27,040
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (paranoia) { var entropyRequired = this._PARANOIA_LEVELS[ paranoia ? paranoia : this._defaultParanoia ]; if (this._strength >= entropyRequired) { return 1.0; } else { return (this._poolStrength > entropyRequired) ? 1.0 : this._poolStrength / entropyRequired; } }
javascript
function (paranoia) { var entropyRequired = this._PARANOIA_LEVELS[ paranoia ? paranoia : this._defaultParanoia ]; if (this._strength >= entropyRequired) { return 1.0; } else { return (this._poolStrength > entropyRequired) ? 1.0 : this._poolStrength / entropyRequired; } }
[ "function", "(", "paranoia", ")", "{", "var", "entropyRequired", "=", "this", ".", "_PARANOIA_LEVELS", "[", "paranoia", "?", "paranoia", ":", "this", ".", "_defaultParanoia", "]", ";", "if", "(", "this", ".", "_strength", ">=", "entropyRequired", ")", "{", "return", "1.0", ";", "}", "else", "{", "return", "(", "this", ".", "_poolStrength", ">", "entropyRequired", ")", "?", "1.0", ":", "this", ".", "_poolStrength", "/", "entropyRequired", ";", "}", "}" ]
Get the generator's progress toward readiness, as a fraction
[ "Get", "the", "generator", "s", "progress", "toward", "readiness", "as", "a", "fraction" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1728-L1738
27,041
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function () { if (this._collectorsStarted) { return; } this._eventListener = { loadTimeCollector: this._bind(this._loadTimeCollector), mouseCollector: this._bind(this._mouseCollector), keyboardCollector: this._bind(this._keyboardCollector), accelerometerCollector: this._bind(this._accelerometerCollector), touchCollector: this._bind(this._touchCollector) }; if (window.addEventListener) { window.addEventListener("load", this._eventListener.loadTimeCollector, false); window.addEventListener("mousemove", this._eventListener.mouseCollector, false); window.addEventListener("keypress", this._eventListener.keyboardCollector, false); window.addEventListener("devicemotion", this._eventListener.accelerometerCollector, false); window.addEventListener("touchmove", this._eventListener.touchCollector, false); } else if (document.attachEvent) { document.attachEvent("onload", this._eventListener.loadTimeCollector); document.attachEvent("onmousemove", this._eventListener.mouseCollector); document.attachEvent("keypress", this._eventListener.keyboardCollector); } else { throw new sjcl.exception.bug("can't attach event"); } this._collectorsStarted = true; }
javascript
function () { if (this._collectorsStarted) { return; } this._eventListener = { loadTimeCollector: this._bind(this._loadTimeCollector), mouseCollector: this._bind(this._mouseCollector), keyboardCollector: this._bind(this._keyboardCollector), accelerometerCollector: this._bind(this._accelerometerCollector), touchCollector: this._bind(this._touchCollector) }; if (window.addEventListener) { window.addEventListener("load", this._eventListener.loadTimeCollector, false); window.addEventListener("mousemove", this._eventListener.mouseCollector, false); window.addEventListener("keypress", this._eventListener.keyboardCollector, false); window.addEventListener("devicemotion", this._eventListener.accelerometerCollector, false); window.addEventListener("touchmove", this._eventListener.touchCollector, false); } else if (document.attachEvent) { document.attachEvent("onload", this._eventListener.loadTimeCollector); document.attachEvent("onmousemove", this._eventListener.mouseCollector); document.attachEvent("keypress", this._eventListener.keyboardCollector); } else { throw new sjcl.exception.bug("can't attach event"); } this._collectorsStarted = true; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "_collectorsStarted", ")", "{", "return", ";", "}", "this", ".", "_eventListener", "=", "{", "loadTimeCollector", ":", "this", ".", "_bind", "(", "this", ".", "_loadTimeCollector", ")", ",", "mouseCollector", ":", "this", ".", "_bind", "(", "this", ".", "_mouseCollector", ")", ",", "keyboardCollector", ":", "this", ".", "_bind", "(", "this", ".", "_keyboardCollector", ")", ",", "accelerometerCollector", ":", "this", ".", "_bind", "(", "this", ".", "_accelerometerCollector", ")", ",", "touchCollector", ":", "this", ".", "_bind", "(", "this", ".", "_touchCollector", ")", "}", ";", "if", "(", "window", ".", "addEventListener", ")", "{", "window", ".", "addEventListener", "(", "\"load\"", ",", "this", ".", "_eventListener", ".", "loadTimeCollector", ",", "false", ")", ";", "window", ".", "addEventListener", "(", "\"mousemove\"", ",", "this", ".", "_eventListener", ".", "mouseCollector", ",", "false", ")", ";", "window", ".", "addEventListener", "(", "\"keypress\"", ",", "this", ".", "_eventListener", ".", "keyboardCollector", ",", "false", ")", ";", "window", ".", "addEventListener", "(", "\"devicemotion\"", ",", "this", ".", "_eventListener", ".", "accelerometerCollector", ",", "false", ")", ";", "window", ".", "addEventListener", "(", "\"touchmove\"", ",", "this", ".", "_eventListener", ".", "touchCollector", ",", "false", ")", ";", "}", "else", "if", "(", "document", ".", "attachEvent", ")", "{", "document", ".", "attachEvent", "(", "\"onload\"", ",", "this", ".", "_eventListener", ".", "loadTimeCollector", ")", ";", "document", ".", "attachEvent", "(", "\"onmousemove\"", ",", "this", ".", "_eventListener", ".", "mouseCollector", ")", ";", "document", ".", "attachEvent", "(", "\"keypress\"", ",", "this", ".", "_eventListener", ".", "keyboardCollector", ")", ";", "}", "else", "{", "throw", "new", "sjcl", ".", "exception", ".", "bug", "(", "\"can't attach event\"", ")", ";", "}", "this", ".", "_collectorsStarted", "=", "true", ";", "}" ]
start the built-in entropy collectors
[ "start", "the", "built", "-", "in", "entropy", "collectors" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1741-L1767
27,042
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function () { if (!this._collectorsStarted) { return; } if (window.removeEventListener) { window.removeEventListener("load", this._eventListener.loadTimeCollector, false); window.removeEventListener("mousemove", this._eventListener.mouseCollector, false); window.removeEventListener("keypress", this._eventListener.keyboardCollector, false); window.removeEventListener("devicemotion", this._eventListener.accelerometerCollector, false); window.removeEventListener("touchmove", this._eventListener.touchCollector, false); } else if (document.detachEvent) { document.detachEvent("onload", this._eventListener.loadTimeCollector); document.detachEvent("onmousemove", this._eventListener.mouseCollector); document.detachEvent("keypress", this._eventListener.keyboardCollector); } this._collectorsStarted = false; }
javascript
function () { if (!this._collectorsStarted) { return; } if (window.removeEventListener) { window.removeEventListener("load", this._eventListener.loadTimeCollector, false); window.removeEventListener("mousemove", this._eventListener.mouseCollector, false); window.removeEventListener("keypress", this._eventListener.keyboardCollector, false); window.removeEventListener("devicemotion", this._eventListener.accelerometerCollector, false); window.removeEventListener("touchmove", this._eventListener.touchCollector, false); } else if (document.detachEvent) { document.detachEvent("onload", this._eventListener.loadTimeCollector); document.detachEvent("onmousemove", this._eventListener.mouseCollector); document.detachEvent("keypress", this._eventListener.keyboardCollector); } this._collectorsStarted = false; }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "_collectorsStarted", ")", "{", "return", ";", "}", "if", "(", "window", ".", "removeEventListener", ")", "{", "window", ".", "removeEventListener", "(", "\"load\"", ",", "this", ".", "_eventListener", ".", "loadTimeCollector", ",", "false", ")", ";", "window", ".", "removeEventListener", "(", "\"mousemove\"", ",", "this", ".", "_eventListener", ".", "mouseCollector", ",", "false", ")", ";", "window", ".", "removeEventListener", "(", "\"keypress\"", ",", "this", ".", "_eventListener", ".", "keyboardCollector", ",", "false", ")", ";", "window", ".", "removeEventListener", "(", "\"devicemotion\"", ",", "this", ".", "_eventListener", ".", "accelerometerCollector", ",", "false", ")", ";", "window", ".", "removeEventListener", "(", "\"touchmove\"", ",", "this", ".", "_eventListener", ".", "touchCollector", ",", "false", ")", ";", "}", "else", "if", "(", "document", ".", "detachEvent", ")", "{", "document", ".", "detachEvent", "(", "\"onload\"", ",", "this", ".", "_eventListener", ".", "loadTimeCollector", ")", ";", "document", ".", "detachEvent", "(", "\"onmousemove\"", ",", "this", ".", "_eventListener", ".", "mouseCollector", ")", ";", "document", ".", "detachEvent", "(", "\"keypress\"", ",", "this", ".", "_eventListener", ".", "keyboardCollector", ")", ";", "}", "this", ".", "_collectorsStarted", "=", "false", ";", "}" ]
stop the built-in entropy collectors
[ "stop", "the", "built", "-", "in", "entropy", "collectors" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1770-L1786
27,043
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (name, cb) { var i, j, cbs=this._callbacks[name], jsTemp=[]; /* I'm not sure if this is necessary; in C++, iterating over a * collection and modifying it at the same time is a no-no. */ for (j in cbs) { if (cbs.hasOwnProperty(j) && cbs[j] === cb) { jsTemp.push(j); } } for (i=0; i<jsTemp.length; i++) { j = jsTemp[i]; delete cbs[j]; } }
javascript
function (name, cb) { var i, j, cbs=this._callbacks[name], jsTemp=[]; /* I'm not sure if this is necessary; in C++, iterating over a * collection and modifying it at the same time is a no-no. */ for (j in cbs) { if (cbs.hasOwnProperty(j) && cbs[j] === cb) { jsTemp.push(j); } } for (i=0; i<jsTemp.length; i++) { j = jsTemp[i]; delete cbs[j]; } }
[ "function", "(", "name", ",", "cb", ")", "{", "var", "i", ",", "j", ",", "cbs", "=", "this", ".", "_callbacks", "[", "name", "]", ",", "jsTemp", "=", "[", "]", ";", "/* I'm not sure if this is necessary; in C++, iterating over a\n * collection and modifying it at the same time is a no-no.\n */", "for", "(", "j", "in", "cbs", ")", "{", "if", "(", "cbs", ".", "hasOwnProperty", "(", "j", ")", "&&", "cbs", "[", "j", "]", "===", "cb", ")", "{", "jsTemp", ".", "push", "(", "j", ")", ";", "}", "}", "for", "(", "i", "=", "0", ";", "i", "<", "jsTemp", ".", "length", ";", "i", "++", ")", "{", "j", "=", "jsTemp", "[", "i", "]", ";", "delete", "cbs", "[", "j", "]", ";", "}", "}" ]
remove an event listener for progress or seeded-ness
[ "remove", "an", "event", "listener", "for", "progress", "or", "seeded", "-", "ness" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1799-L1816
27,044
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function () { for (var i=0; i<4; i++) { this._counter[i] = this._counter[i]+1 | 0; if (this._counter[i]) { break; } } return this._cipher.encrypt(this._counter); }
javascript
function () { for (var i=0; i<4; i++) { this._counter[i] = this._counter[i]+1 | 0; if (this._counter[i]) { break; } } return this._cipher.encrypt(this._counter); }
[ "function", "(", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "this", ".", "_counter", "[", "i", "]", "=", "this", ".", "_counter", "[", "i", "]", "+", "1", "|", "0", ";", "if", "(", "this", ".", "_counter", "[", "i", "]", ")", "{", "break", ";", "}", "}", "return", "this", ".", "_cipher", ".", "encrypt", "(", "this", ".", "_counter", ")", ";", "}" ]
Generate 4 random words, no reseed, no gate. @private
[ "Generate", "4", "random", "words", "no", "reseed", "no", "gate", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1828-L1834
27,045
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (seedWords) { this._key = sjcl.hash.sha256.hash(this._key.concat(seedWords)); this._cipher = new sjcl.cipher.aes(this._key); for (var i=0; i<4; i++) { this._counter[i] = this._counter[i]+1 | 0; if (this._counter[i]) { break; } } }
javascript
function (seedWords) { this._key = sjcl.hash.sha256.hash(this._key.concat(seedWords)); this._cipher = new sjcl.cipher.aes(this._key); for (var i=0; i<4; i++) { this._counter[i] = this._counter[i]+1 | 0; if (this._counter[i]) { break; } } }
[ "function", "(", "seedWords", ")", "{", "this", ".", "_key", "=", "sjcl", ".", "hash", ".", "sha256", ".", "hash", "(", "this", ".", "_key", ".", "concat", "(", "seedWords", ")", ")", ";", "this", ".", "_cipher", "=", "new", "sjcl", ".", "cipher", ".", "aes", "(", "this", ".", "_key", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "this", ".", "_counter", "[", "i", "]", "=", "this", ".", "_counter", "[", "i", "]", "+", "1", "|", "0", ";", "if", "(", "this", ".", "_counter", "[", "i", "]", ")", "{", "break", ";", "}", "}", "}" ]
Reseed the generator with the given words @private
[ "Reseed", "the", "generator", "with", "the", "given", "words" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1847-L1854
27,046
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (full) { var reseedData = [], strength = 0, i; this._nextReseed = reseedData[0] = (new Date()).valueOf() + this._MILLISECONDS_PER_RESEED; for (i=0; i<16; i++) { /* On some browsers, this is cryptographically random. So we might * as well toss it in the pot and stir... */ reseedData.push(Math.random()*0x100000000|0); } for (i=0; i<this._pools.length; i++) { reseedData = reseedData.concat(this._pools[i].finalize()); strength += this._poolEntropy[i]; this._poolEntropy[i] = 0; if (!full && (this._reseedCount & (1<<i))) { break; } } /* if we used the last pool, push a new one onto the stack */ if (this._reseedCount >= 1 << this._pools.length) { this._pools.push(new sjcl.hash.sha256()); this._poolEntropy.push(0); } /* how strong was this reseed? */ this._poolStrength -= strength; if (strength > this._strength) { this._strength = strength; } this._reseedCount ++; this._reseed(reseedData); }
javascript
function (full) { var reseedData = [], strength = 0, i; this._nextReseed = reseedData[0] = (new Date()).valueOf() + this._MILLISECONDS_PER_RESEED; for (i=0; i<16; i++) { /* On some browsers, this is cryptographically random. So we might * as well toss it in the pot and stir... */ reseedData.push(Math.random()*0x100000000|0); } for (i=0; i<this._pools.length; i++) { reseedData = reseedData.concat(this._pools[i].finalize()); strength += this._poolEntropy[i]; this._poolEntropy[i] = 0; if (!full && (this._reseedCount & (1<<i))) { break; } } /* if we used the last pool, push a new one onto the stack */ if (this._reseedCount >= 1 << this._pools.length) { this._pools.push(new sjcl.hash.sha256()); this._poolEntropy.push(0); } /* how strong was this reseed? */ this._poolStrength -= strength; if (strength > this._strength) { this._strength = strength; } this._reseedCount ++; this._reseed(reseedData); }
[ "function", "(", "full", ")", "{", "var", "reseedData", "=", "[", "]", ",", "strength", "=", "0", ",", "i", ";", "this", ".", "_nextReseed", "=", "reseedData", "[", "0", "]", "=", "(", "new", "Date", "(", ")", ")", ".", "valueOf", "(", ")", "+", "this", ".", "_MILLISECONDS_PER_RESEED", ";", "for", "(", "i", "=", "0", ";", "i", "<", "16", ";", "i", "++", ")", "{", "/* On some browsers, this is cryptographically random. So we might\n * as well toss it in the pot and stir...\n */", "reseedData", ".", "push", "(", "Math", ".", "random", "(", ")", "*", "0x100000000", "|", "0", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "this", ".", "_pools", ".", "length", ";", "i", "++", ")", "{", "reseedData", "=", "reseedData", ".", "concat", "(", "this", ".", "_pools", "[", "i", "]", ".", "finalize", "(", ")", ")", ";", "strength", "+=", "this", ".", "_poolEntropy", "[", "i", "]", ";", "this", ".", "_poolEntropy", "[", "i", "]", "=", "0", ";", "if", "(", "!", "full", "&&", "(", "this", ".", "_reseedCount", "&", "(", "1", "<<", "i", ")", ")", ")", "{", "break", ";", "}", "}", "/* if we used the last pool, push a new one onto the stack */", "if", "(", "this", ".", "_reseedCount", ">=", "1", "<<", "this", ".", "_pools", ".", "length", ")", "{", "this", ".", "_pools", ".", "push", "(", "new", "sjcl", ".", "hash", ".", "sha256", "(", ")", ")", ";", "this", ".", "_poolEntropy", ".", "push", "(", "0", ")", ";", "}", "/* how strong was this reseed? */", "this", ".", "_poolStrength", "-=", "strength", ";", "if", "(", "strength", ">", "this", ".", "_strength", ")", "{", "this", ".", "_strength", "=", "strength", ";", "}", "this", ".", "_reseedCount", "++", ";", "this", ".", "_reseed", "(", "reseedData", ")", ";", "}" ]
reseed the data from the entropy pools @param full If set, use all the entropy pools in the reseed.
[ "reseed", "the", "data", "from", "the", "entropy", "pools" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L1859-L1894
27,047
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (obj) { var i, out='{', comma=''; for (i in obj) { if (obj.hasOwnProperty(i)) { if (!i.match(/^[a-z0-9]+$/i)) { throw new sjcl.exception.invalid("json encode: invalid property name"); } out += comma + '"' + i + '":'; comma = ','; switch (typeof obj[i]) { case 'number': case 'boolean': out += obj[i]; break; case 'string': out += '"' + escape(obj[i]) + '"'; break; case 'object': out += '"' + sjcl.codec.base64.fromBits(obj[i],0) + '"'; break; default: throw new sjcl.exception.bug("json encode: unsupported type"); } } } return out+'}'; }
javascript
function (obj) { var i, out='{', comma=''; for (i in obj) { if (obj.hasOwnProperty(i)) { if (!i.match(/^[a-z0-9]+$/i)) { throw new sjcl.exception.invalid("json encode: invalid property name"); } out += comma + '"' + i + '":'; comma = ','; switch (typeof obj[i]) { case 'number': case 'boolean': out += obj[i]; break; case 'string': out += '"' + escape(obj[i]) + '"'; break; case 'object': out += '"' + sjcl.codec.base64.fromBits(obj[i],0) + '"'; break; default: throw new sjcl.exception.bug("json encode: unsupported type"); } } } return out+'}'; }
[ "function", "(", "obj", ")", "{", "var", "i", ",", "out", "=", "'{'", ",", "comma", "=", "''", ";", "for", "(", "i", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "if", "(", "!", "i", ".", "match", "(", "/", "^[a-z0-9]+$", "/", "i", ")", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "invalid", "(", "\"json encode: invalid property name\"", ")", ";", "}", "out", "+=", "comma", "+", "'\"'", "+", "i", "+", "'\":'", ";", "comma", "=", "','", ";", "switch", "(", "typeof", "obj", "[", "i", "]", ")", "{", "case", "'number'", ":", "case", "'boolean'", ":", "out", "+=", "obj", "[", "i", "]", ";", "break", ";", "case", "'string'", ":", "out", "+=", "'\"'", "+", "escape", "(", "obj", "[", "i", "]", ")", "+", "'\"'", ";", "break", ";", "case", "'object'", ":", "out", "+=", "'\"'", "+", "sjcl", ".", "codec", ".", "base64", ".", "fromBits", "(", "obj", "[", "i", "]", ",", "0", ")", "+", "'\"'", ";", "break", ";", "default", ":", "throw", "new", "sjcl", ".", "exception", ".", "bug", "(", "\"json encode: unsupported type\"", ")", ";", "}", "}", "}", "return", "out", "+", "'}'", ";", "}" ]
Encode a flat structure into a JSON string. @param {Object} obj The structure to encode. @return {String} A JSON string. @throws {sjcl.exception.invalid} if obj has a non-alphanumeric property. @throws {sjcl.exception.bug} if a parameter has an unsupported type.
[ "Encode", "a", "flat", "structure", "into", "a", "JSON", "string", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L2182-L2212
27,048
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (target, src, requireSame) { if (target === undefined) { target = {}; } if (src === undefined) { return target; } var i; for (i in src) { if (src.hasOwnProperty(i)) { if (requireSame && target[i] !== undefined && target[i] !== src[i]) { throw new sjcl.exception.invalid("required parameter overridden"); } target[i] = src[i]; } } return target; }
javascript
function (target, src, requireSame) { if (target === undefined) { target = {}; } if (src === undefined) { return target; } var i; for (i in src) { if (src.hasOwnProperty(i)) { if (requireSame && target[i] !== undefined && target[i] !== src[i]) { throw new sjcl.exception.invalid("required parameter overridden"); } target[i] = src[i]; } } return target; }
[ "function", "(", "target", ",", "src", ",", "requireSame", ")", "{", "if", "(", "target", "===", "undefined", ")", "{", "target", "=", "{", "}", ";", "}", "if", "(", "src", "===", "undefined", ")", "{", "return", "target", ";", "}", "var", "i", ";", "for", "(", "i", "in", "src", ")", "{", "if", "(", "src", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "if", "(", "requireSame", "&&", "target", "[", "i", "]", "!==", "undefined", "&&", "target", "[", "i", "]", "!==", "src", "[", "i", "]", ")", "{", "throw", "new", "sjcl", ".", "exception", ".", "invalid", "(", "\"required parameter overridden\"", ")", ";", "}", "target", "[", "i", "]", "=", "src", "[", "i", "]", ";", "}", "}", "return", "target", ";", "}" ]
Insert all elements of src into target, modifying and returning target. @param {Object} target The object to be modified. @param {Object} src The object to pull data from. @param {boolean} [requireSame=false] If true, throw an exception if any field of target differs from corresponding field of src. @return {Object} target. @private
[ "Insert", "all", "elements", "of", "src", "into", "target", "modifying", "and", "returning", "target", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L2248-L2261
27,049
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (plus, minus) { var out = {}, i; for (i in plus) { if (plus.hasOwnProperty(i) && plus[i] !== minus[i]) { out[i] = plus[i]; } } return out; }
javascript
function (plus, minus) { var out = {}, i; for (i in plus) { if (plus.hasOwnProperty(i) && plus[i] !== minus[i]) { out[i] = plus[i]; } } return out; }
[ "function", "(", "plus", ",", "minus", ")", "{", "var", "out", "=", "{", "}", ",", "i", ";", "for", "(", "i", "in", "plus", ")", "{", "if", "(", "plus", ".", "hasOwnProperty", "(", "i", ")", "&&", "plus", "[", "i", "]", "!==", "minus", "[", "i", "]", ")", "{", "out", "[", "i", "]", "=", "plus", "[", "i", "]", ";", "}", "}", "return", "out", ";", "}" ]
Remove all elements of minus from plus. Does not modify plus. @private
[ "Remove", "all", "elements", "of", "minus", "from", "plus", ".", "Does", "not", "modify", "plus", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L2266-L2276
27,050
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js
function (src, filter) { var out = {}, i; for (i=0; i<filter.length; i++) { if (src[filter[i]] !== undefined) { out[filter[i]] = src[filter[i]]; } } return out; }
javascript
function (src, filter) { var out = {}, i; for (i=0; i<filter.length; i++) { if (src[filter[i]] !== undefined) { out[filter[i]] = src[filter[i]]; } } return out; }
[ "function", "(", "src", ",", "filter", ")", "{", "var", "out", "=", "{", "}", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "filter", ".", "length", ";", "i", "++", ")", "{", "if", "(", "src", "[", "filter", "[", "i", "]", "]", "!==", "undefined", ")", "{", "out", "[", "filter", "[", "i", "]", "]", "=", "src", "[", "filter", "[", "i", "]", "]", ";", "}", "}", "return", "out", ";", "}" ]
Return only the specified elements of src. @private
[ "Return", "only", "the", "specified", "elements", "of", "src", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-secure-storage/www/sjcl_ss.js#L2281-L2289
27,051
sony/cdp-js
packages/cafeteria/docs/localize/resource_conv.js
function (singular) { var self = this; this.singluer = singular; this.requireDefaultFile = false; // [CDP customize] this.folderName = '..\\..\\app\\res\\locales'; // [CDP customize] this.formatLine = function (key, value) { var v2 = '' + value; return ' "' + key + '": "' + v2.replace(/"/g, '\\"') + '",\n'; }; this.formatLastLine = function (key, value) { var v2 = '' + value; return ' "' + key + '": "' + v2.replace(/"/g, '\\"') + '"\n'; }; this.formatComment = function (comment) { return ''; }; this.formatEmptyLine = function () { return ''; }; this.formatHeader = function (localeKey) { return self.singluer ? '{\n' : ''; }; this.formatFooter = function (localeKey) { // [CDP customize] return self.singluer ? '\n}' : '\n'; // [CDP customize] }; this.getFilePath = function (folderPath, localeKey) { return folderPath + '\\messages.' + localeKey + '.json'; }; this.normalizeLines = function (lines) { // format: json-singluer, noop. if (self.singluer) { return lines; } // ensure JSON object (function () { if (typeof JSON !== 'object') { var fileStream = fso.openTextFile('.\\json2.js'); var fileData = fileStream.readAll(); fileStream.Close(); /*jshint evil: true */ eval(fileData); /*jshint evil: false */ } }()); var flatJsonObj = (function () { var flatSrc = '{\n'; for (var i = 0, n = lines.length; i < n; i++) { var line = lines[i]; if (i === n - 1) { // last line line = line.split(',')[0]; } flatSrc += line; } flatSrc += '\n}'; return JSON.parse(flatSrc); }()); var jsonText = (function (flat) { var normalize = {}; for (var key in flat) { var value = flat[key]; var keys = key.split("."); var temp = normalize; for (var i = 0, n = keys.length; i < n; i++) { if (!temp[keys[i]]) { if (i < n - 1) { temp[keys[i]] = {}; } else { temp[keys[i]] = value; } } temp = temp[keys[i]]; } } return JSON.stringify(normalize, null, 4); }(flatJsonObj)); return jsonText.split('\r\n'); }; }
javascript
function (singular) { var self = this; this.singluer = singular; this.requireDefaultFile = false; // [CDP customize] this.folderName = '..\\..\\app\\res\\locales'; // [CDP customize] this.formatLine = function (key, value) { var v2 = '' + value; return ' "' + key + '": "' + v2.replace(/"/g, '\\"') + '",\n'; }; this.formatLastLine = function (key, value) { var v2 = '' + value; return ' "' + key + '": "' + v2.replace(/"/g, '\\"') + '"\n'; }; this.formatComment = function (comment) { return ''; }; this.formatEmptyLine = function () { return ''; }; this.formatHeader = function (localeKey) { return self.singluer ? '{\n' : ''; }; this.formatFooter = function (localeKey) { // [CDP customize] return self.singluer ? '\n}' : '\n'; // [CDP customize] }; this.getFilePath = function (folderPath, localeKey) { return folderPath + '\\messages.' + localeKey + '.json'; }; this.normalizeLines = function (lines) { // format: json-singluer, noop. if (self.singluer) { return lines; } // ensure JSON object (function () { if (typeof JSON !== 'object') { var fileStream = fso.openTextFile('.\\json2.js'); var fileData = fileStream.readAll(); fileStream.Close(); /*jshint evil: true */ eval(fileData); /*jshint evil: false */ } }()); var flatJsonObj = (function () { var flatSrc = '{\n'; for (var i = 0, n = lines.length; i < n; i++) { var line = lines[i]; if (i === n - 1) { // last line line = line.split(',')[0]; } flatSrc += line; } flatSrc += '\n}'; return JSON.parse(flatSrc); }()); var jsonText = (function (flat) { var normalize = {}; for (var key in flat) { var value = flat[key]; var keys = key.split("."); var temp = normalize; for (var i = 0, n = keys.length; i < n; i++) { if (!temp[keys[i]]) { if (i < n - 1) { temp[keys[i]] = {}; } else { temp[keys[i]] = value; } } temp = temp[keys[i]]; } } return JSON.stringify(normalize, null, 4); }(flatJsonObj)); return jsonText.split('\r\n'); }; }
[ "function", "(", "singular", ")", "{", "var", "self", "=", "this", ";", "this", ".", "singluer", "=", "singular", ";", "this", ".", "requireDefaultFile", "=", "false", ";", "// [CDP customize]", "this", ".", "folderName", "=", "'..\\\\..\\\\app\\\\res\\\\locales'", ";", "// [CDP customize]", "this", ".", "formatLine", "=", "function", "(", "key", ",", "value", ")", "{", "var", "v2", "=", "''", "+", "value", ";", "return", "' \"'", "+", "key", "+", "'\": \"'", "+", "v2", ".", "replace", "(", "/", "\"", "/", "g", ",", "'\\\\\"'", ")", "+", "'\",\\n'", ";", "}", ";", "this", ".", "formatLastLine", "=", "function", "(", "key", ",", "value", ")", "{", "var", "v2", "=", "''", "+", "value", ";", "return", "' \"'", "+", "key", "+", "'\": \"'", "+", "v2", ".", "replace", "(", "/", "\"", "/", "g", ",", "'\\\\\"'", ")", "+", "'\"\\n'", ";", "}", ";", "this", ".", "formatComment", "=", "function", "(", "comment", ")", "{", "return", "''", ";", "}", ";", "this", ".", "formatEmptyLine", "=", "function", "(", ")", "{", "return", "''", ";", "}", ";", "this", ".", "formatHeader", "=", "function", "(", "localeKey", ")", "{", "return", "self", ".", "singluer", "?", "'{\\n'", ":", "''", ";", "}", ";", "this", ".", "formatFooter", "=", "function", "(", "localeKey", ")", "{", "// [CDP customize]", "return", "self", ".", "singluer", "?", "'\\n}'", ":", "'\\n'", ";", "// [CDP customize]", "}", ";", "this", ".", "getFilePath", "=", "function", "(", "folderPath", ",", "localeKey", ")", "{", "return", "folderPath", "+", "'\\\\messages.'", "+", "localeKey", "+", "'.json'", ";", "}", ";", "this", ".", "normalizeLines", "=", "function", "(", "lines", ")", "{", "// format: json-singluer, noop.", "if", "(", "self", ".", "singluer", ")", "{", "return", "lines", ";", "}", "// ensure JSON object", "(", "function", "(", ")", "{", "if", "(", "typeof", "JSON", "!==", "'object'", ")", "{", "var", "fileStream", "=", "fso", ".", "openTextFile", "(", "'.\\\\json2.js'", ")", ";", "var", "fileData", "=", "fileStream", ".", "readAll", "(", ")", ";", "fileStream", ".", "Close", "(", ")", ";", "/*jshint evil: true */", "eval", "(", "fileData", ")", ";", "/*jshint evil: false */", "}", "}", "(", ")", ")", ";", "var", "flatJsonObj", "=", "(", "function", "(", ")", "{", "var", "flatSrc", "=", "'{\\n'", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "lines", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "var", "line", "=", "lines", "[", "i", "]", ";", "if", "(", "i", "===", "n", "-", "1", ")", "{", "// last line", "line", "=", "line", ".", "split", "(", "','", ")", "[", "0", "]", ";", "}", "flatSrc", "+=", "line", ";", "}", "flatSrc", "+=", "'\\n}'", ";", "return", "JSON", ".", "parse", "(", "flatSrc", ")", ";", "}", "(", ")", ")", ";", "var", "jsonText", "=", "(", "function", "(", "flat", ")", "{", "var", "normalize", "=", "{", "}", ";", "for", "(", "var", "key", "in", "flat", ")", "{", "var", "value", "=", "flat", "[", "key", "]", ";", "var", "keys", "=", "key", ".", "split", "(", "\".\"", ")", ";", "var", "temp", "=", "normalize", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "keys", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "if", "(", "!", "temp", "[", "keys", "[", "i", "]", "]", ")", "{", "if", "(", "i", "<", "n", "-", "1", ")", "{", "temp", "[", "keys", "[", "i", "]", "]", "=", "{", "}", ";", "}", "else", "{", "temp", "[", "keys", "[", "i", "]", "]", "=", "value", ";", "}", "}", "temp", "=", "temp", "[", "keys", "[", "i", "]", "]", ";", "}", "}", "return", "JSON", ".", "stringify", "(", "normalize", ",", "null", ",", "4", ")", ";", "}", "(", "flatJsonObj", ")", ")", ";", "return", "jsonText", ".", "split", "(", "'\\r\\n'", ")", ";", "}", ";", "}" ]
JSON file formatter
[ "JSON", "file", "formatter" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/docs/localize/resource_conv.js#L34-L117
27,052
sony/cdp-js
packages/cafeteria/docs/localize/resource_conv.js
function() { this.requireDefaultFile = true; this.folderName = 'conf'; this.isDefaultLocale = function (localeKey) { if (localeKey == 'en-us' || localeKey == 'en-US') { return true; } return false; }; this.getDefaultFilePath = function (folderPath) { return folderPath + '\\' + 'messages'; }; this.formatLine = function (key, value) { return key + '=' + value + '\n'; }; this.formatLastLine = function (key, value) { return this.formatLine(key, value); }; this.formatComment = function (comment) { return comment + '\n'; }; this.formatEmptyLine = function () { return '\n'; }; this.formatHeader = function (localeKey) { return ''; }; this.formatFooter = function (localeKey) { return ''; }; this.getFilePath = function (folderPath, localeKey) { return folderPath + '\\messages.' + localeKey; }; this.normalizeLines = function (lines) { // noop return lines; }; }
javascript
function() { this.requireDefaultFile = true; this.folderName = 'conf'; this.isDefaultLocale = function (localeKey) { if (localeKey == 'en-us' || localeKey == 'en-US') { return true; } return false; }; this.getDefaultFilePath = function (folderPath) { return folderPath + '\\' + 'messages'; }; this.formatLine = function (key, value) { return key + '=' + value + '\n'; }; this.formatLastLine = function (key, value) { return this.formatLine(key, value); }; this.formatComment = function (comment) { return comment + '\n'; }; this.formatEmptyLine = function () { return '\n'; }; this.formatHeader = function (localeKey) { return ''; }; this.formatFooter = function (localeKey) { return ''; }; this.getFilePath = function (folderPath, localeKey) { return folderPath + '\\messages.' + localeKey; }; this.normalizeLines = function (lines) { // noop return lines; }; }
[ "function", "(", ")", "{", "this", ".", "requireDefaultFile", "=", "true", ";", "this", ".", "folderName", "=", "'conf'", ";", "this", ".", "isDefaultLocale", "=", "function", "(", "localeKey", ")", "{", "if", "(", "localeKey", "==", "'en-us'", "||", "localeKey", "==", "'en-US'", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", ";", "this", ".", "getDefaultFilePath", "=", "function", "(", "folderPath", ")", "{", "return", "folderPath", "+", "'\\\\'", "+", "'messages'", ";", "}", ";", "this", ".", "formatLine", "=", "function", "(", "key", ",", "value", ")", "{", "return", "key", "+", "'='", "+", "value", "+", "'\\n'", ";", "}", ";", "this", ".", "formatLastLine", "=", "function", "(", "key", ",", "value", ")", "{", "return", "this", ".", "formatLine", "(", "key", ",", "value", ")", ";", "}", ";", "this", ".", "formatComment", "=", "function", "(", "comment", ")", "{", "return", "comment", "+", "'\\n'", ";", "}", ";", "this", ".", "formatEmptyLine", "=", "function", "(", ")", "{", "return", "'\\n'", ";", "}", ";", "this", ".", "formatHeader", "=", "function", "(", "localeKey", ")", "{", "return", "''", ";", "}", ";", "this", ".", "formatFooter", "=", "function", "(", "localeKey", ")", "{", "return", "''", ";", "}", ";", "this", ".", "getFilePath", "=", "function", "(", "folderPath", ",", "localeKey", ")", "{", "return", "folderPath", "+", "'\\\\messages.'", "+", "localeKey", ";", "}", ";", "this", ".", "normalizeLines", "=", "function", "(", "lines", ")", "{", "// noop", "return", "lines", ";", "}", ";", "}" ]
Play framework language file formatter
[ "Play", "framework", "language", "file", "formatter" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/docs/localize/resource_conv.js#L122-L153
27,053
sony/cdp-js
packages/cafeteria/docs/localize/resource_conv.js
findExcelFile
function findExcelFile() { var files = fso.getFolder(".").Files; for (var e = new Enumerator(files) ; !e.atEnd() ; e.moveNext()) { var file = e.item(); // [CDP customize] var extXLSX = '.xlsx'; var extODS = '.ods'; if (file.Name.substr(file.Name.length - extXLSX.length) === extXLSX) { return file.Path; } else if (file.Name.substr(file.Name.length - extODS.length) === extODS) { return file.Path; } // [CDP customize] } return null; }
javascript
function findExcelFile() { var files = fso.getFolder(".").Files; for (var e = new Enumerator(files) ; !e.atEnd() ; e.moveNext()) { var file = e.item(); // [CDP customize] var extXLSX = '.xlsx'; var extODS = '.ods'; if (file.Name.substr(file.Name.length - extXLSX.length) === extXLSX) { return file.Path; } else if (file.Name.substr(file.Name.length - extODS.length) === extODS) { return file.Path; } // [CDP customize] } return null; }
[ "function", "findExcelFile", "(", ")", "{", "var", "files", "=", "fso", ".", "getFolder", "(", "\".\"", ")", ".", "Files", ";", "for", "(", "var", "e", "=", "new", "Enumerator", "(", "files", ")", ";", "!", "e", ".", "atEnd", "(", ")", ";", "e", ".", "moveNext", "(", ")", ")", "{", "var", "file", "=", "e", ".", "item", "(", ")", ";", "// [CDP customize]", "var", "extXLSX", "=", "'.xlsx'", ";", "var", "extODS", "=", "'.ods'", ";", "if", "(", "file", ".", "Name", ".", "substr", "(", "file", ".", "Name", ".", "length", "-", "extXLSX", ".", "length", ")", "===", "extXLSX", ")", "{", "return", "file", ".", "Path", ";", "}", "else", "if", "(", "file", ".", "Name", ".", "substr", "(", "file", ".", "Name", ".", "length", "-", "extODS", ".", "length", ")", "===", "extODS", ")", "{", "return", "file", ".", "Path", ";", "}", "// [CDP customize]", "}", "return", "null", ";", "}" ]
Find first .ods file
[ "Find", "first", ".", "ods", "file" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/docs/localize/resource_conv.js#L361-L376
27,054
sony/cdp-js
packages/master-tasks/tasks/srcmap.js
getNodeFromFiles
function getNodeFromFiles(scriptFile, mapFile) { if (fs.existsSync(scriptFile) && fs.existsSync(mapFile)) { try { return SourceNode.fromStringWithSourceMap( getScriptFromFile(scriptFile), new SourceMapConsumer(getMapFromMapFile(mapFile)) ); } catch (error) { console.error('getNodeFromFiles() error: ' + error); return new SourceNode(); } } else { return new SourceNode(); } }
javascript
function getNodeFromFiles(scriptFile, mapFile) { if (fs.existsSync(scriptFile) && fs.existsSync(mapFile)) { try { return SourceNode.fromStringWithSourceMap( getScriptFromFile(scriptFile), new SourceMapConsumer(getMapFromMapFile(mapFile)) ); } catch (error) { console.error('getNodeFromFiles() error: ' + error); return new SourceNode(); } } else { return new SourceNode(); } }
[ "function", "getNodeFromFiles", "(", "scriptFile", ",", "mapFile", ")", "{", "if", "(", "fs", ".", "existsSync", "(", "scriptFile", ")", "&&", "fs", ".", "existsSync", "(", "mapFile", ")", ")", "{", "try", "{", "return", "SourceNode", ".", "fromStringWithSourceMap", "(", "getScriptFromFile", "(", "scriptFile", ")", ",", "new", "SourceMapConsumer", "(", "getMapFromMapFile", "(", "mapFile", ")", ")", ")", ";", "}", "catch", "(", "error", ")", "{", "console", ".", "error", "(", "'getNodeFromFiles() error: '", "+", "error", ")", ";", "return", "new", "SourceNode", "(", ")", ";", "}", "}", "else", "{", "return", "new", "SourceNode", "(", ")", ";", "}", "}" ]
get sourceNode from script and map files
[ "get", "sourceNode", "from", "script", "and", "map", "files" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/master-tasks/tasks/srcmap.js#L30-L44
27,055
sony/cdp-js
packages/master-tasks/tasks/srcmap.js
getNodeFromCode
function getNodeFromCode(code) { if (convert.mapFileCommentRegex.test(code)) { try { return SourceNode.fromStringWithSourceMap( convertCode2Script(code), new SourceMapConsumer(convert.fromComment(code).toObject()) ); } catch (error) { console.error('getNodeFromCode() error: ' + error); const node = new SourceNode(); node.add(convertCode2Script(code)); return node; } } else { const node = new SourceNode(); node.add(convertCode2Script(code)); return node; } }
javascript
function getNodeFromCode(code) { if (convert.mapFileCommentRegex.test(code)) { try { return SourceNode.fromStringWithSourceMap( convertCode2Script(code), new SourceMapConsumer(convert.fromComment(code).toObject()) ); } catch (error) { console.error('getNodeFromCode() error: ' + error); const node = new SourceNode(); node.add(convertCode2Script(code)); return node; } } else { const node = new SourceNode(); node.add(convertCode2Script(code)); return node; } }
[ "function", "getNodeFromCode", "(", "code", ")", "{", "if", "(", "convert", ".", "mapFileCommentRegex", ".", "test", "(", "code", ")", ")", "{", "try", "{", "return", "SourceNode", ".", "fromStringWithSourceMap", "(", "convertCode2Script", "(", "code", ")", ",", "new", "SourceMapConsumer", "(", "convert", ".", "fromComment", "(", "code", ")", ".", "toObject", "(", ")", ")", ")", ";", "}", "catch", "(", "error", ")", "{", "console", ".", "error", "(", "'getNodeFromCode() error: '", "+", "error", ")", ";", "const", "node", "=", "new", "SourceNode", "(", ")", ";", "node", ".", "add", "(", "convertCode2Script", "(", "code", ")", ")", ";", "return", "node", ";", "}", "}", "else", "{", "const", "node", "=", "new", "SourceNode", "(", ")", ";", "node", ".", "add", "(", "convertCode2Script", "(", "code", ")", ")", ";", "return", "node", ";", "}", "}" ]
get sourceNode from code
[ "get", "sourceNode", "from", "code" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/master-tasks/tasks/srcmap.js#L47-L65
27,056
sony/cdp-js
packages/master-tasks/tasks/srcmap.js
getCodeFromNode
function getCodeFromNode(node, renameSources, options) { const code_map = getCodeMap(node); const rename = renameSources; const objMap = code_map.map.toJSON(); let i, n; if (rename) { if ('string' === typeof rename) { for (i = 0, n = objMap.sources.length; i < n; i++) { objMap.sources[i] = rename + objMap.sources[i]; } } else if ('function' === typeof rename) { for (i = 0, n = objMap.sources.length; i < n; i++) { objMap.sources[i] = rename(objMap.sources[i]); } } else { console.warn('unexpected type of rename: ' + typeof rename); } } return node.toString() + convert.fromObject(objMap) .toComment(options) .replace(/charset=utf-8;/gm, '') .replace('data:application/json;', 'data:application/json;charset=utf-8;') + '\n'; }
javascript
function getCodeFromNode(node, renameSources, options) { const code_map = getCodeMap(node); const rename = renameSources; const objMap = code_map.map.toJSON(); let i, n; if (rename) { if ('string' === typeof rename) { for (i = 0, n = objMap.sources.length; i < n; i++) { objMap.sources[i] = rename + objMap.sources[i]; } } else if ('function' === typeof rename) { for (i = 0, n = objMap.sources.length; i < n; i++) { objMap.sources[i] = rename(objMap.sources[i]); } } else { console.warn('unexpected type of rename: ' + typeof rename); } } return node.toString() + convert.fromObject(objMap) .toComment(options) .replace(/charset=utf-8;/gm, '') .replace('data:application/json;', 'data:application/json;charset=utf-8;') + '\n'; }
[ "function", "getCodeFromNode", "(", "node", ",", "renameSources", ",", "options", ")", "{", "const", "code_map", "=", "getCodeMap", "(", "node", ")", ";", "const", "rename", "=", "renameSources", ";", "const", "objMap", "=", "code_map", ".", "map", ".", "toJSON", "(", ")", ";", "let", "i", ",", "n", ";", "if", "(", "rename", ")", "{", "if", "(", "'string'", "===", "typeof", "rename", ")", "{", "for", "(", "i", "=", "0", ",", "n", "=", "objMap", ".", "sources", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "objMap", ".", "sources", "[", "i", "]", "=", "rename", "+", "objMap", ".", "sources", "[", "i", "]", ";", "}", "}", "else", "if", "(", "'function'", "===", "typeof", "rename", ")", "{", "for", "(", "i", "=", "0", ",", "n", "=", "objMap", ".", "sources", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "objMap", ".", "sources", "[", "i", "]", "=", "rename", "(", "objMap", ".", "sources", "[", "i", "]", ")", ";", "}", "}", "else", "{", "console", ".", "warn", "(", "'unexpected type of rename: '", "+", "typeof", "rename", ")", ";", "}", "}", "return", "node", ".", "toString", "(", ")", "+", "convert", ".", "fromObject", "(", "objMap", ")", ".", "toComment", "(", "options", ")", ".", "replace", "(", "/", "charset=utf-8;", "/", "gm", ",", "''", ")", ".", "replace", "(", "'data:application/json;'", ",", "'data:application/json;charset=utf-8;'", ")", "+", "'\\n'", ";", "}" ]
get code with inline-source-map from file SourceNode
[ "get", "code", "with", "inline", "-", "source", "-", "map", "from", "file", "SourceNode" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/master-tasks/tasks/srcmap.js#L68-L93
27,057
sony/cdp-js
packages/master-tasks/tasks/srcmap.js
separateScriptAndMapFromScriptFile
function separateScriptAndMapFromScriptFile(scriptFile, multiline, mapPath) { const node = getNodeFromScriptFile(scriptFile); mapPath = mapPath || path.basename(scriptFile) + '.map'; return { script: node.toString().replace(/\r\n/gm, '\n') + ( multiline ? ('/*# sourceMappingURL=' + mapPath + ' */') : ('//# sourceMappingURL=' + mapPath) ), map: JSON.stringify(getCodeMap(node).map.toJSON()), }; }
javascript
function separateScriptAndMapFromScriptFile(scriptFile, multiline, mapPath) { const node = getNodeFromScriptFile(scriptFile); mapPath = mapPath || path.basename(scriptFile) + '.map'; return { script: node.toString().replace(/\r\n/gm, '\n') + ( multiline ? ('/*# sourceMappingURL=' + mapPath + ' */') : ('//# sourceMappingURL=' + mapPath) ), map: JSON.stringify(getCodeMap(node).map.toJSON()), }; }
[ "function", "separateScriptAndMapFromScriptFile", "(", "scriptFile", ",", "multiline", ",", "mapPath", ")", "{", "const", "node", "=", "getNodeFromScriptFile", "(", "scriptFile", ")", ";", "mapPath", "=", "mapPath", "||", "path", ".", "basename", "(", "scriptFile", ")", "+", "'.map'", ";", "return", "{", "script", ":", "node", ".", "toString", "(", ")", ".", "replace", "(", "/", "\\r\\n", "/", "gm", ",", "'\\n'", ")", "+", "(", "multiline", "?", "(", "'/*# sourceMappingURL='", "+", "mapPath", "+", "' */'", ")", ":", "(", "'//# sourceMappingURL='", "+", "mapPath", ")", ")", ",", "map", ":", "JSON", ".", "stringify", "(", "getCodeMap", "(", "node", ")", ".", "map", ".", "toJSON", "(", ")", ")", ",", "}", ";", "}" ]
separate source script and map from file
[ "separate", "source", "script", "and", "map", "from", "file" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/master-tasks/tasks/srcmap.js#L96-L107
27,058
sony/cdp-js
packages/master-tasks/tasks/srcmap.js
getCodeMap
function getCodeMap(node) { const code_map = node.toStringWithSourceMap(); // patch node.walkSourceContents(function (sourceFile, sourceContent) { if (!code_map.map._sources.has(sourceFile)) { code_map.map._sources.add(sourceFile); } }); return code_map; }
javascript
function getCodeMap(node) { const code_map = node.toStringWithSourceMap(); // patch node.walkSourceContents(function (sourceFile, sourceContent) { if (!code_map.map._sources.has(sourceFile)) { code_map.map._sources.add(sourceFile); } }); return code_map; }
[ "function", "getCodeMap", "(", "node", ")", "{", "const", "code_map", "=", "node", ".", "toStringWithSourceMap", "(", ")", ";", "// patch", "node", ".", "walkSourceContents", "(", "function", "(", "sourceFile", ",", "sourceContent", ")", "{", "if", "(", "!", "code_map", ".", "map", ".", "_sources", ".", "has", "(", "sourceFile", ")", ")", "{", "code_map", ".", "map", ".", "_sources", ".", "add", "(", "sourceFile", ")", ";", "}", "}", ")", ";", "return", "code_map", ";", "}" ]
get code map with path from node
[ "get", "code", "map", "with", "path", "from", "node" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/master-tasks/tasks/srcmap.js#L140-L151
27,059
npm/ndm
lib/config.js
Config
function Config(opts) { _.extend(this, { appName: 'ndm', // used by rc. serviceJsonPath: path.resolve(process.cwd(), 'service.json'), tmpServiceJsonPath: null, // used during install phase. logsDirectory: this.defaultLogsDirectory(), env: process.env, uid: null, gid: null, console: null, // In upstart 1.4, where should logs be sent? <logged|output|owner|none> sudo: null, headless: false, filter: null, modulePrefix: '', nodeBin: process.execPath, baseWorkingDirectory: path.resolve(process.cwd()), globalPackage: false, platform: null, // override the platform ndm generates services for platformApis: { ubuntu: require('./platform-apis/ubuntu'), centos: require('./platform-apis/centos'), darwin: require('./platform-apis/darwin'), initd: require('./platform-apis/init-d') }, parsers: { sudo: function(v) { return v.toString() === 'true' }, headless: function(v) { return v.toString() === 'true' }, globalPackage: function(v) { return v.toString() === 'true' } } }, opts); // allow platform to be overridden. this.platform = this.os(); // allow platform and env to be overridden before applying. _.extend(this, this._getEnv(), opts); this._rcOverride(); }
javascript
function Config(opts) { _.extend(this, { appName: 'ndm', // used by rc. serviceJsonPath: path.resolve(process.cwd(), 'service.json'), tmpServiceJsonPath: null, // used during install phase. logsDirectory: this.defaultLogsDirectory(), env: process.env, uid: null, gid: null, console: null, // In upstart 1.4, where should logs be sent? <logged|output|owner|none> sudo: null, headless: false, filter: null, modulePrefix: '', nodeBin: process.execPath, baseWorkingDirectory: path.resolve(process.cwd()), globalPackage: false, platform: null, // override the platform ndm generates services for platformApis: { ubuntu: require('./platform-apis/ubuntu'), centos: require('./platform-apis/centos'), darwin: require('./platform-apis/darwin'), initd: require('./platform-apis/init-d') }, parsers: { sudo: function(v) { return v.toString() === 'true' }, headless: function(v) { return v.toString() === 'true' }, globalPackage: function(v) { return v.toString() === 'true' } } }, opts); // allow platform to be overridden. this.platform = this.os(); // allow platform and env to be overridden before applying. _.extend(this, this._getEnv(), opts); this._rcOverride(); }
[ "function", "Config", "(", "opts", ")", "{", "_", ".", "extend", "(", "this", ",", "{", "appName", ":", "'ndm'", ",", "// used by rc.", "serviceJsonPath", ":", "path", ".", "resolve", "(", "process", ".", "cwd", "(", ")", ",", "'service.json'", ")", ",", "tmpServiceJsonPath", ":", "null", ",", "// used during install phase.", "logsDirectory", ":", "this", ".", "defaultLogsDirectory", "(", ")", ",", "env", ":", "process", ".", "env", ",", "uid", ":", "null", ",", "gid", ":", "null", ",", "console", ":", "null", ",", "// In upstart 1.4, where should logs be sent? <logged|output|owner|none>", "sudo", ":", "null", ",", "headless", ":", "false", ",", "filter", ":", "null", ",", "modulePrefix", ":", "''", ",", "nodeBin", ":", "process", ".", "execPath", ",", "baseWorkingDirectory", ":", "path", ".", "resolve", "(", "process", ".", "cwd", "(", ")", ")", ",", "globalPackage", ":", "false", ",", "platform", ":", "null", ",", "// override the platform ndm generates services for", "platformApis", ":", "{", "ubuntu", ":", "require", "(", "'./platform-apis/ubuntu'", ")", ",", "centos", ":", "require", "(", "'./platform-apis/centos'", ")", ",", "darwin", ":", "require", "(", "'./platform-apis/darwin'", ")", ",", "initd", ":", "require", "(", "'./platform-apis/init-d'", ")", "}", ",", "parsers", ":", "{", "sudo", ":", "function", "(", "v", ")", "{", "return", "v", ".", "toString", "(", ")", "===", "'true'", "}", ",", "headless", ":", "function", "(", "v", ")", "{", "return", "v", ".", "toString", "(", ")", "===", "'true'", "}", ",", "globalPackage", ":", "function", "(", "v", ")", "{", "return", "v", ".", "toString", "(", ")", "===", "'true'", "}", "}", "}", ",", "opts", ")", ";", "// allow platform to be overridden.", "this", ".", "platform", "=", "this", ".", "os", "(", ")", ";", "// allow platform and env to be overridden before applying.", "_", ".", "extend", "(", "this", ",", "this", ".", "_getEnv", "(", ")", ",", "opts", ")", ";", "this", ".", "_rcOverride", "(", ")", ";", "}" ]
handles loading and detecting configuration pulling together OS-specific variables, ENV, and args.
[ "handles", "loading", "and", "detecting", "configuration", "pulling", "together", "OS", "-", "specific", "variables", "ENV", "and", "args", "." ]
0c5c50c409c365d5304bedc15754ddffa86aedbc
https://github.com/npm/ndm/blob/0c5c50c409c365d5304bedc15754ddffa86aedbc/lib/config.js#L11-L49
27,060
sony/cdp-js
packages/cafeteria/platforms/ios/cordova/lib/prepare.js
getLaunchStoryboardContentsJSON
function getLaunchStoryboardContentsJSON(splashScreens, launchStoryboardImagesDir) { var platformLaunchStoryboardImages = mapLaunchStoryboardContents(splashScreens, launchStoryboardImagesDir); var contentsJSON = { images: [], info: { author: 'Xcode', version: 1 } }; contentsJSON.images = platformLaunchStoryboardImages.map(function(item) { var newItem = { idiom: item.idiom, scale: item.scale }; // Xcode doesn't want any size class property if the class is "any" // If our size class is "com", Xcode wants "compact". if (item.width !== CDV_ANY_SIZE_CLASS) { newItem['width-class'] = IMAGESET_COMPACT_SIZE_CLASS; } if (item.height !== CDV_ANY_SIZE_CLASS) { newItem['height-class'] = IMAGESET_COMPACT_SIZE_CLASS; } // Xcode doesn't want a filename property if there's no image for these traits if (item.filename) { newItem.filename = item.filename; } return newItem; }); return contentsJSON; }
javascript
function getLaunchStoryboardContentsJSON(splashScreens, launchStoryboardImagesDir) { var platformLaunchStoryboardImages = mapLaunchStoryboardContents(splashScreens, launchStoryboardImagesDir); var contentsJSON = { images: [], info: { author: 'Xcode', version: 1 } }; contentsJSON.images = platformLaunchStoryboardImages.map(function(item) { var newItem = { idiom: item.idiom, scale: item.scale }; // Xcode doesn't want any size class property if the class is "any" // If our size class is "com", Xcode wants "compact". if (item.width !== CDV_ANY_SIZE_CLASS) { newItem['width-class'] = IMAGESET_COMPACT_SIZE_CLASS; } if (item.height !== CDV_ANY_SIZE_CLASS) { newItem['height-class'] = IMAGESET_COMPACT_SIZE_CLASS; } // Xcode doesn't want a filename property if there's no image for these traits if (item.filename) { newItem.filename = item.filename; } return newItem; }); return contentsJSON; }
[ "function", "getLaunchStoryboardContentsJSON", "(", "splashScreens", ",", "launchStoryboardImagesDir", ")", "{", "var", "platformLaunchStoryboardImages", "=", "mapLaunchStoryboardContents", "(", "splashScreens", ",", "launchStoryboardImagesDir", ")", ";", "var", "contentsJSON", "=", "{", "images", ":", "[", "]", ",", "info", ":", "{", "author", ":", "'Xcode'", ",", "version", ":", "1", "}", "}", ";", "contentsJSON", ".", "images", "=", "platformLaunchStoryboardImages", ".", "map", "(", "function", "(", "item", ")", "{", "var", "newItem", "=", "{", "idiom", ":", "item", ".", "idiom", ",", "scale", ":", "item", ".", "scale", "}", ";", "// Xcode doesn't want any size class property if the class is \"any\"", "// If our size class is \"com\", Xcode wants \"compact\". ", "if", "(", "item", ".", "width", "!==", "CDV_ANY_SIZE_CLASS", ")", "{", "newItem", "[", "'width-class'", "]", "=", "IMAGESET_COMPACT_SIZE_CLASS", ";", "}", "if", "(", "item", ".", "height", "!==", "CDV_ANY_SIZE_CLASS", ")", "{", "newItem", "[", "'height-class'", "]", "=", "IMAGESET_COMPACT_SIZE_CLASS", ";", "}", "// Xcode doesn't want a filename property if there's no image for these traits ", "if", "(", "item", ".", "filename", ")", "{", "newItem", ".", "filename", "=", "item", ".", "filename", ";", "}", "return", "newItem", ";", "}", ")", ";", "return", "contentsJSON", ";", "}" ]
Builds the object that represents the contents.json file for the LaunchStoryboard image set. The resulting return looks like this: { images: [ { idiom: 'universal|ipad|iphone', scale: '1x|2x|3x', width-class: undefined|'compact', height-class: undefined|'compact' }, ... ], info: { author: 'Xcode', version: 1 } } A bit of minor logic is used to map from the array of images returned from mapLaunchStoryboardContents to the format requried by Xcode. @param {Array<Object>} splashScreens splash screens as defined in config.xml for this platform @param {string} launchStoryboardImagesDir project-root/Images.xcassets/LaunchStoryboard.imageset/ @return {Object}
[ "Builds", "the", "object", "that", "represents", "the", "contents", ".", "json", "file", "for", "the", "LaunchStoryboard", "image", "set", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/platforms/ios/cordova/lib/prepare.js#L659-L691
27,061
sony/cdp-js
packages/cafeteria/platforms/ios/cordova/lib/prepare.js
checkIfBuildSettingsNeedUpdatedForLaunchStoryboard
function checkIfBuildSettingsNeedUpdatedForLaunchStoryboard(platformConfig, infoPlist) { var hasLaunchStoryboardImages = platformHasLaunchStoryboardImages(platformConfig); var hasLegacyLaunchImages = platformHasLegacyLaunchImages(platformConfig); var currentLaunchStoryboard = infoPlist[UI_LAUNCH_STORYBOARD_NAME]; if (hasLaunchStoryboardImages && currentLaunchStoryboard == CDV_LAUNCH_STORYBOARD_NAME && !hasLegacyLaunchImages) { // don't need legacy launch images if we are using our launch storyboard // so we do need to update the project file events.emit('verbose', 'Need to update build settings because project is using our launch storyboard.'); return true; } else if (hasLegacyLaunchImages && !currentLaunchStoryboard) { // we do need to ensure legacy launch images are used if there's no launch storyboard present // so we do need to update the project file events.emit('verbose', 'Need to update build settings because project is using legacy launch images and no storyboard.'); return true; } events.emit('verbose', 'No need to update build settings for launch storyboard support.'); return false; }
javascript
function checkIfBuildSettingsNeedUpdatedForLaunchStoryboard(platformConfig, infoPlist) { var hasLaunchStoryboardImages = platformHasLaunchStoryboardImages(platformConfig); var hasLegacyLaunchImages = platformHasLegacyLaunchImages(platformConfig); var currentLaunchStoryboard = infoPlist[UI_LAUNCH_STORYBOARD_NAME]; if (hasLaunchStoryboardImages && currentLaunchStoryboard == CDV_LAUNCH_STORYBOARD_NAME && !hasLegacyLaunchImages) { // don't need legacy launch images if we are using our launch storyboard // so we do need to update the project file events.emit('verbose', 'Need to update build settings because project is using our launch storyboard.'); return true; } else if (hasLegacyLaunchImages && !currentLaunchStoryboard) { // we do need to ensure legacy launch images are used if there's no launch storyboard present // so we do need to update the project file events.emit('verbose', 'Need to update build settings because project is using legacy launch images and no storyboard.'); return true; } events.emit('verbose', 'No need to update build settings for launch storyboard support.'); return false; }
[ "function", "checkIfBuildSettingsNeedUpdatedForLaunchStoryboard", "(", "platformConfig", ",", "infoPlist", ")", "{", "var", "hasLaunchStoryboardImages", "=", "platformHasLaunchStoryboardImages", "(", "platformConfig", ")", ";", "var", "hasLegacyLaunchImages", "=", "platformHasLegacyLaunchImages", "(", "platformConfig", ")", ";", "var", "currentLaunchStoryboard", "=", "infoPlist", "[", "UI_LAUNCH_STORYBOARD_NAME", "]", ";", "if", "(", "hasLaunchStoryboardImages", "&&", "currentLaunchStoryboard", "==", "CDV_LAUNCH_STORYBOARD_NAME", "&&", "!", "hasLegacyLaunchImages", ")", "{", "// don't need legacy launch images if we are using our launch storyboard", "// so we do need to update the project file", "events", ".", "emit", "(", "'verbose'", ",", "'Need to update build settings because project is using our launch storyboard.'", ")", ";", "return", "true", ";", "}", "else", "if", "(", "hasLegacyLaunchImages", "&&", "!", "currentLaunchStoryboard", ")", "{", "// we do need to ensure legacy launch images are used if there's no launch storyboard present", "// so we do need to update the project file", "events", ".", "emit", "(", "'verbose'", ",", "'Need to update build settings because project is using legacy launch images and no storyboard.'", ")", ";", "return", "true", ";", "}", "events", ".", "emit", "(", "'verbose'", ",", "'No need to update build settings for launch storyboard support.'", ")", ";", "return", "false", ";", "}" ]
Determines if the project's build settings may need to be updated for launch storyboard support
[ "Determines", "if", "the", "project", "s", "build", "settings", "may", "need", "to", "be", "updated", "for", "launch", "storyboard", "support" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/platforms/ios/cordova/lib/prepare.js#L697-L715
27,062
sony/cdp-js
packages/cafeteria/plugins/cordova-plugin-cdp-nativebridge/www/cdp.plugin.nativebridge.js
NativeBridge
function NativeBridge(feature, options) { if (!(this instanceof NativeBridge)) { return new NativeBridge(feature, options); } this._feature = feature; this._objectId = "object:" + _utils.createUUID(); this._execTaskHistory = {}; }
javascript
function NativeBridge(feature, options) { if (!(this instanceof NativeBridge)) { return new NativeBridge(feature, options); } this._feature = feature; this._objectId = "object:" + _utils.createUUID(); this._execTaskHistory = {}; }
[ "function", "NativeBridge", "(", "feature", ",", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "NativeBridge", ")", ")", "{", "return", "new", "NativeBridge", "(", "feature", ",", "options", ")", ";", "}", "this", ".", "_feature", "=", "feature", ";", "this", ".", "_objectId", "=", "\"object:\"", "+", "_utils", ".", "createUUID", "(", ")", ";", "this", ".", "_execTaskHistory", "=", "{", "}", ";", "}" ]
\~english constructor @param feature {Feature} [in] feature information. @param options {ConstructOptions?} [in] construction options. \~japanese constructor @param feature {Feature} [in] 機能情報 @param options {ConstructOptions?} [in] オプション情報
[ "\\", "~english", "constructor" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/plugins/cordova-plugin-cdp-nativebridge/www/cdp.plugin.nativebridge.js#L94-L101
27,063
richardeoin/nodejs-plotter
plotter.js
moving_maximum
function moving_maximum(array, n) { var nums = []; for (i in array) { if (_.isNumber(array[i])) { nums.push(array[i]); if (nums.length > n) { nums.splice(0,1); /* Remove the first element of the array */ } /* Take the average of the n items in this array */ var maximum = _.max(nums); array[i] = maximum; } } return array; }
javascript
function moving_maximum(array, n) { var nums = []; for (i in array) { if (_.isNumber(array[i])) { nums.push(array[i]); if (nums.length > n) { nums.splice(0,1); /* Remove the first element of the array */ } /* Take the average of the n items in this array */ var maximum = _.max(nums); array[i] = maximum; } } return array; }
[ "function", "moving_maximum", "(", "array", ",", "n", ")", "{", "var", "nums", "=", "[", "]", ";", "for", "(", "i", "in", "array", ")", "{", "if", "(", "_", ".", "isNumber", "(", "array", "[", "i", "]", ")", ")", "{", "nums", ".", "push", "(", "array", "[", "i", "]", ")", ";", "if", "(", "nums", ".", "length", ">", "n", ")", "{", "nums", ".", "splice", "(", "0", ",", "1", ")", ";", "/* Remove the first element of the array */", "}", "/* Take the average of the n items in this array */", "var", "maximum", "=", "_", ".", "max", "(", "nums", ")", ";", "array", "[", "i", "]", "=", "maximum", ";", "}", "}", "return", "array", ";", "}" ]
Performs a n-point maximum on array.
[ "Performs", "a", "n", "-", "point", "maximum", "on", "array", "." ]
06460f357334c32d5a255b038c6f5bc6215d8b86
https://github.com/richardeoin/nodejs-plotter/blob/06460f357334c32d5a255b038c6f5bc6215d8b86/plotter.js#L34-L50
27,064
richardeoin/nodejs-plotter
plotter.js
apply_moving_filter
function apply_moving_filter(set, filter, n) { if (!_.isNumber(n)) { n = 3; } for (series in set) { /* For each series */ /* Apply the filter */ set[series] = filter(set[series], n); } return set; }
javascript
function apply_moving_filter(set, filter, n) { if (!_.isNumber(n)) { n = 3; } for (series in set) { /* For each series */ /* Apply the filter */ set[series] = filter(set[series], n); } return set; }
[ "function", "apply_moving_filter", "(", "set", ",", "filter", ",", "n", ")", "{", "if", "(", "!", "_", ".", "isNumber", "(", "n", ")", ")", "{", "n", "=", "3", ";", "}", "for", "(", "series", "in", "set", ")", "{", "/* For each series */", "/* Apply the filter */", "set", "[", "series", "]", "=", "filter", "(", "set", "[", "series", "]", ",", "n", ")", ";", "}", "return", "set", ";", "}" ]
Applys an n-point moving filter to a set of series.
[ "Applys", "an", "n", "-", "point", "moving", "filter", "to", "a", "set", "of", "series", "." ]
06460f357334c32d5a255b038c6f5bc6215d8b86
https://github.com/richardeoin/nodejs-plotter/blob/06460f357334c32d5a255b038c6f5bc6215d8b86/plotter.js#L54-L63
27,065
richardeoin/nodejs-plotter
plotter.js
time_format
function time_format(options) { if (_.isString(options.time)) { /* Translate the string we've been given into a format */ switch(options.time) { case 'days': case 'Days': return "%d/%m"; case 'hours': case 'Hours': return "%H:%M"; default: /* Presume we've been given a gnuplot-readable time format string */ return options.time; } } else { /* Just default to hours */ return "%H:%M"; } }
javascript
function time_format(options) { if (_.isString(options.time)) { /* Translate the string we've been given into a format */ switch(options.time) { case 'days': case 'Days': return "%d/%m"; case 'hours': case 'Hours': return "%H:%M"; default: /* Presume we've been given a gnuplot-readable time format string */ return options.time; } } else { /* Just default to hours */ return "%H:%M"; } }
[ "function", "time_format", "(", "options", ")", "{", "if", "(", "_", ".", "isString", "(", "options", ".", "time", ")", ")", "{", "/* Translate the string we've been given into a format */", "switch", "(", "options", ".", "time", ")", "{", "case", "'days'", ":", "case", "'Days'", ":", "return", "\"%d/%m\"", ";", "case", "'hours'", ":", "case", "'Hours'", ":", "return", "\"%H:%M\"", ";", "default", ":", "/* Presume we've been given a gnuplot-readable time format string */", "return", "options", ".", "time", ";", "}", "}", "else", "{", "/* Just default to hours */", "return", "\"%H:%M\"", ";", "}", "}" ]
Returns the string to give to gnuplot based on the value of options.time.
[ "Returns", "the", "string", "to", "give", "to", "gnuplot", "based", "on", "the", "value", "of", "options", ".", "time", "." ]
06460f357334c32d5a255b038c6f5bc6215d8b86
https://github.com/richardeoin/nodejs-plotter/blob/06460f357334c32d5a255b038c6f5bc6215d8b86/plotter.js#L67-L83
27,066
richardeoin/nodejs-plotter
plotter.js
setup_gnuplot
function setup_gnuplot(gnuplot, options) { if (options.format === 'svg') { /* Setup gnuplot for SVG */ gnuplot.stdin.write('set term svg fname \"Helvetica\" fsize 14\n'); } else if (options.format == 'pdf') { /* PDF: setup Gnuplot output to postscript so ps2pdf can interpret it */ gnuplot.stdin.write('set term postscript landscape enhanced color dashed' + '\"Helvetica\" 14\n'); } else { /* Setup gnuplot for png */ gnuplot.stdin.write('set term png\n'); } /* Formatting Options */ if (options.time) { gnuplot.stdin.write('set xdata time\n'); gnuplot.stdin.write('set timefmt "%s"\n'); gnuplot.stdin.write('set format x "' + time_format(options.time) + '"\n'); gnuplot.stdin.write('set xlabel "time"\n'); } if (options.title) { gnuplot.stdin.write('set title "'+options.title+'"\n'); } if (options.logscale) { gnuplot.stdin.write('set logscale y\n'); } if (options.xlabel) { gnuplot.stdin.write('set xlabel "'+options.xlabel+'"\n'); } if (options.ylabel) { gnuplot.stdin.write('set ylabel "'+options.ylabel+'"\n'); } /* Setup ticks */ gnuplot.stdin.write('set grid xtics ytics mxtics\n'); gnuplot.stdin.write('set mxtics\n'); if (options.nokey) { gnuplot.stdin.write('set nokey\n'); } }
javascript
function setup_gnuplot(gnuplot, options) { if (options.format === 'svg') { /* Setup gnuplot for SVG */ gnuplot.stdin.write('set term svg fname \"Helvetica\" fsize 14\n'); } else if (options.format == 'pdf') { /* PDF: setup Gnuplot output to postscript so ps2pdf can interpret it */ gnuplot.stdin.write('set term postscript landscape enhanced color dashed' + '\"Helvetica\" 14\n'); } else { /* Setup gnuplot for png */ gnuplot.stdin.write('set term png\n'); } /* Formatting Options */ if (options.time) { gnuplot.stdin.write('set xdata time\n'); gnuplot.stdin.write('set timefmt "%s"\n'); gnuplot.stdin.write('set format x "' + time_format(options.time) + '"\n'); gnuplot.stdin.write('set xlabel "time"\n'); } if (options.title) { gnuplot.stdin.write('set title "'+options.title+'"\n'); } if (options.logscale) { gnuplot.stdin.write('set logscale y\n'); } if (options.xlabel) { gnuplot.stdin.write('set xlabel "'+options.xlabel+'"\n'); } if (options.ylabel) { gnuplot.stdin.write('set ylabel "'+options.ylabel+'"\n'); } /* Setup ticks */ gnuplot.stdin.write('set grid xtics ytics mxtics\n'); gnuplot.stdin.write('set mxtics\n'); if (options.nokey) { gnuplot.stdin.write('set nokey\n'); } }
[ "function", "setup_gnuplot", "(", "gnuplot", ",", "options", ")", "{", "if", "(", "options", ".", "format", "===", "'svg'", ")", "{", "/* Setup gnuplot for SVG */", "gnuplot", ".", "stdin", ".", "write", "(", "'set term svg fname \\\"Helvetica\\\" fsize 14\\n'", ")", ";", "}", "else", "if", "(", "options", ".", "format", "==", "'pdf'", ")", "{", "/* PDF: setup Gnuplot output to postscript so ps2pdf can interpret it */", "gnuplot", ".", "stdin", ".", "write", "(", "'set term postscript landscape enhanced color dashed'", "+", "'\\\"Helvetica\\\" 14\\n'", ")", ";", "}", "else", "{", "/* Setup gnuplot for png */", "gnuplot", ".", "stdin", ".", "write", "(", "'set term png\\n'", ")", ";", "}", "/* Formatting Options */", "if", "(", "options", ".", "time", ")", "{", "gnuplot", ".", "stdin", ".", "write", "(", "'set xdata time\\n'", ")", ";", "gnuplot", ".", "stdin", ".", "write", "(", "'set timefmt \"%s\"\\n'", ")", ";", "gnuplot", ".", "stdin", ".", "write", "(", "'set format x \"'", "+", "time_format", "(", "options", ".", "time", ")", "+", "'\"\\n'", ")", ";", "gnuplot", ".", "stdin", ".", "write", "(", "'set xlabel \"time\"\\n'", ")", ";", "}", "if", "(", "options", ".", "title", ")", "{", "gnuplot", ".", "stdin", ".", "write", "(", "'set title \"'", "+", "options", ".", "title", "+", "'\"\\n'", ")", ";", "}", "if", "(", "options", ".", "logscale", ")", "{", "gnuplot", ".", "stdin", ".", "write", "(", "'set logscale y\\n'", ")", ";", "}", "if", "(", "options", ".", "xlabel", ")", "{", "gnuplot", ".", "stdin", ".", "write", "(", "'set xlabel \"'", "+", "options", ".", "xlabel", "+", "'\"\\n'", ")", ";", "}", "if", "(", "options", ".", "ylabel", ")", "{", "gnuplot", ".", "stdin", ".", "write", "(", "'set ylabel \"'", "+", "options", ".", "ylabel", "+", "'\"\\n'", ")", ";", "}", "/* Setup ticks */", "gnuplot", ".", "stdin", ".", "write", "(", "'set grid xtics ytics mxtics\\n'", ")", ";", "gnuplot", ".", "stdin", ".", "write", "(", "'set mxtics\\n'", ")", ";", "if", "(", "options", ".", "nokey", ")", "{", "gnuplot", ".", "stdin", ".", "write", "(", "'set nokey\\n'", ")", ";", "}", "}" ]
Sets up gnuplot based on the properties we're given in the options object.
[ "Sets", "up", "gnuplot", "based", "on", "the", "properties", "we", "re", "given", "in", "the", "options", "object", "." ]
06460f357334c32d5a255b038c6f5bc6215d8b86
https://github.com/richardeoin/nodejs-plotter/blob/06460f357334c32d5a255b038c6f5bc6215d8b86/plotter.js#L87-L125
27,067
npm/ndm
lib/platform-apis/platform-base.js
PlatformBase
function PlatformBase(opts) { _.extend(this, { platform: null, // path to template to use for service generation, // use of a template may be optional. template: null, logger: require('../logger') }, opts); }
javascript
function PlatformBase(opts) { _.extend(this, { platform: null, // path to template to use for service generation, // use of a template may be optional. template: null, logger: require('../logger') }, opts); }
[ "function", "PlatformBase", "(", "opts", ")", "{", "_", ".", "extend", "(", "this", ",", "{", "platform", ":", "null", ",", "// path to template to use for service generation,", "// use of a template may be optional.", "template", ":", "null", ",", "logger", ":", "require", "(", "'../logger'", ")", "}", ",", "opts", ")", ";", "}" ]
An API for executing OS-specific commands, and generating OS-specific daemon scripts.
[ "An", "API", "for", "executing", "OS", "-", "specific", "commands", "and", "generating", "OS", "-", "specific", "daemon", "scripts", "." ]
0c5c50c409c365d5304bedc15754ddffa86aedbc
https://github.com/npm/ndm/blob/0c5c50c409c365d5304bedc15754ddffa86aedbc/lib/platform-apis/platform-base.js#L9-L17
27,068
sony/cdp-js
packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js
function(vector) { var n = this.elements.length; var V = vector.elements || vector; if (n != V.length) { return false; } do { if (Math.abs(this.elements[n-1] - V[n-1]) > Sylvester.precision) { return false; } } while (--n); return true; }
javascript
function(vector) { var n = this.elements.length; var V = vector.elements || vector; if (n != V.length) { return false; } do { if (Math.abs(this.elements[n-1] - V[n-1]) > Sylvester.precision) { return false; } } while (--n); return true; }
[ "function", "(", "vector", ")", "{", "var", "n", "=", "this", ".", "elements", ".", "length", ";", "var", "V", "=", "vector", ".", "elements", "||", "vector", ";", "if", "(", "n", "!=", "V", ".", "length", ")", "{", "return", "false", ";", "}", "do", "{", "if", "(", "Math", ".", "abs", "(", "this", ".", "elements", "[", "n", "-", "1", "]", "-", "V", "[", "n", "-", "1", "]", ")", ">", "Sylvester", ".", "precision", ")", "{", "return", "false", ";", "}", "}", "while", "(", "--", "n", ")", ";", "return", "true", ";", "}" ]
Returns true iff the vector is equal to the argument
[ "Returns", "true", "iff", "the", "vector", "is", "equal", "to", "the", "argument" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js#L47-L55
27,069
sony/cdp-js
packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js
function(vector) { var V = vector.elements || vector; var i, product = 0, n = this.elements.length; if (n != V.length) { return null; } do { product += this.elements[n-1] * V[n-1]; } while (--n); return product; }
javascript
function(vector) { var V = vector.elements || vector; var i, product = 0, n = this.elements.length; if (n != V.length) { return null; } do { product += this.elements[n-1] * V[n-1]; } while (--n); return product; }
[ "function", "(", "vector", ")", "{", "var", "V", "=", "vector", ".", "elements", "||", "vector", ";", "var", "i", ",", "product", "=", "0", ",", "n", "=", "this", ".", "elements", ".", "length", ";", "if", "(", "n", "!=", "V", ".", "length", ")", "{", "return", "null", ";", "}", "do", "{", "product", "+=", "this", ".", "elements", "[", "n", "-", "1", "]", "*", "V", "[", "n", "-", "1", "]", ";", "}", "while", "(", "--", "n", ")", ";", "return", "product", ";", "}" ]
Returns the scalar product of the vector with the argument Both vectors must have equal dimensionality
[ "Returns", "the", "scalar", "product", "of", "the", "vector", "with", "the", "argument", "Both", "vectors", "must", "have", "equal", "dimensionality" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js#L147-L153
27,070
sony/cdp-js
packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js
function(obj) { if (obj.anchor) { return obj.distanceFrom(this); } var V = obj.elements || obj; if (V.length != this.elements.length) { return null; } var sum = 0, part; this.each(function(x, i) { part = x - V[i-1]; sum += part * part; }); return Math.sqrt(sum); }
javascript
function(obj) { if (obj.anchor) { return obj.distanceFrom(this); } var V = obj.elements || obj; if (V.length != this.elements.length) { return null; } var sum = 0, part; this.each(function(x, i) { part = x - V[i-1]; sum += part * part; }); return Math.sqrt(sum); }
[ "function", "(", "obj", ")", "{", "if", "(", "obj", ".", "anchor", ")", "{", "return", "obj", ".", "distanceFrom", "(", "this", ")", ";", "}", "var", "V", "=", "obj", ".", "elements", "||", "obj", ";", "if", "(", "V", ".", "length", "!=", "this", ".", "elements", ".", "length", ")", "{", "return", "null", ";", "}", "var", "sum", "=", "0", ",", "part", ";", "this", ".", "each", "(", "function", "(", "x", ",", "i", ")", "{", "part", "=", "x", "-", "V", "[", "i", "-", "1", "]", ";", "sum", "+=", "part", "*", "part", ";", "}", ")", ";", "return", "Math", ".", "sqrt", "(", "sum", ")", ";", "}" ]
Returns the vector's distance from the argument, when considered as a point in space
[ "Returns", "the", "vector", "s", "distance", "from", "the", "argument", "when", "considered", "as", "a", "point", "in", "space" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js#L207-L217
27,071
sony/cdp-js
packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js
function() { if (!this.isSquare()) { return null; } var tr = this.elements[0][0], n = this.elements.length - 1, k = n, i; do { i = k - n + 1; tr += this.elements[i][i]; } while (--n); return tr; }
javascript
function() { if (!this.isSquare()) { return null; } var tr = this.elements[0][0], n = this.elements.length - 1, k = n, i; do { i = k - n + 1; tr += this.elements[i][i]; } while (--n); return tr; }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "isSquare", "(", ")", ")", "{", "return", "null", ";", "}", "var", "tr", "=", "this", ".", "elements", "[", "0", "]", "[", "0", "]", ",", "n", "=", "this", ".", "elements", ".", "length", "-", "1", ",", "k", "=", "n", ",", "i", ";", "do", "{", "i", "=", "k", "-", "n", "+", "1", ";", "tr", "+=", "this", ".", "elements", "[", "i", "]", "[", "i", "]", ";", "}", "while", "(", "--", "n", ")", ";", "return", "tr", ";", "}" ]
Returns the trace for square matrices
[ "Returns", "the", "trace", "for", "square", "matrices" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js#L599-L606
27,072
sony/cdp-js
packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js
function(obj) { if (obj.normal) { return obj.distanceFrom(this); } if (obj.direction) { // obj is a line if (this.isParallelTo(obj)) { return this.distanceFrom(obj.anchor); } var N = this.direction.cross(obj.direction).toUnitVector().elements; var A = this.anchor.elements, B = obj.anchor.elements; return Math.abs((A[0] - B[0]) * N[0] + (A[1] - B[1]) * N[1] + (A[2] - B[2]) * N[2]); } else { // obj is a point var P = obj.elements || obj; var A = this.anchor.elements, D = this.direction.elements; var PA1 = P[0] - A[0], PA2 = P[1] - A[1], PA3 = (P[2] || 0) - A[2]; var modPA = Math.sqrt(PA1*PA1 + PA2*PA2 + PA3*PA3); if (modPA === 0) return 0; // Assumes direction vector is normalized var cosTheta = (PA1 * D[0] + PA2 * D[1] + PA3 * D[2]) / modPA; var sin2 = 1 - cosTheta*cosTheta; return Math.abs(modPA * Math.sqrt(sin2 < 0 ? 0 : sin2)); } }
javascript
function(obj) { if (obj.normal) { return obj.distanceFrom(this); } if (obj.direction) { // obj is a line if (this.isParallelTo(obj)) { return this.distanceFrom(obj.anchor); } var N = this.direction.cross(obj.direction).toUnitVector().elements; var A = this.anchor.elements, B = obj.anchor.elements; return Math.abs((A[0] - B[0]) * N[0] + (A[1] - B[1]) * N[1] + (A[2] - B[2]) * N[2]); } else { // obj is a point var P = obj.elements || obj; var A = this.anchor.elements, D = this.direction.elements; var PA1 = P[0] - A[0], PA2 = P[1] - A[1], PA3 = (P[2] || 0) - A[2]; var modPA = Math.sqrt(PA1*PA1 + PA2*PA2 + PA3*PA3); if (modPA === 0) return 0; // Assumes direction vector is normalized var cosTheta = (PA1 * D[0] + PA2 * D[1] + PA3 * D[2]) / modPA; var sin2 = 1 - cosTheta*cosTheta; return Math.abs(modPA * Math.sqrt(sin2 < 0 ? 0 : sin2)); } }
[ "function", "(", "obj", ")", "{", "if", "(", "obj", ".", "normal", ")", "{", "return", "obj", ".", "distanceFrom", "(", "this", ")", ";", "}", "if", "(", "obj", ".", "direction", ")", "{", "// obj is a line", "if", "(", "this", ".", "isParallelTo", "(", "obj", ")", ")", "{", "return", "this", ".", "distanceFrom", "(", "obj", ".", "anchor", ")", ";", "}", "var", "N", "=", "this", ".", "direction", ".", "cross", "(", "obj", ".", "direction", ")", ".", "toUnitVector", "(", ")", ".", "elements", ";", "var", "A", "=", "this", ".", "anchor", ".", "elements", ",", "B", "=", "obj", ".", "anchor", ".", "elements", ";", "return", "Math", ".", "abs", "(", "(", "A", "[", "0", "]", "-", "B", "[", "0", "]", ")", "*", "N", "[", "0", "]", "+", "(", "A", "[", "1", "]", "-", "B", "[", "1", "]", ")", "*", "N", "[", "1", "]", "+", "(", "A", "[", "2", "]", "-", "B", "[", "2", "]", ")", "*", "N", "[", "2", "]", ")", ";", "}", "else", "{", "// obj is a point", "var", "P", "=", "obj", ".", "elements", "||", "obj", ";", "var", "A", "=", "this", ".", "anchor", ".", "elements", ",", "D", "=", "this", ".", "direction", ".", "elements", ";", "var", "PA1", "=", "P", "[", "0", "]", "-", "A", "[", "0", "]", ",", "PA2", "=", "P", "[", "1", "]", "-", "A", "[", "1", "]", ",", "PA3", "=", "(", "P", "[", "2", "]", "||", "0", ")", "-", "A", "[", "2", "]", ";", "var", "modPA", "=", "Math", ".", "sqrt", "(", "PA1", "*", "PA1", "+", "PA2", "*", "PA2", "+", "PA3", "*", "PA3", ")", ";", "if", "(", "modPA", "===", "0", ")", "return", "0", ";", "// Assumes direction vector is normalized", "var", "cosTheta", "=", "(", "PA1", "*", "D", "[", "0", "]", "+", "PA2", "*", "D", "[", "1", "]", "+", "PA3", "*", "D", "[", "2", "]", ")", "/", "modPA", ";", "var", "sin2", "=", "1", "-", "cosTheta", "*", "cosTheta", ";", "return", "Math", ".", "abs", "(", "modPA", "*", "Math", ".", "sqrt", "(", "sin2", "<", "0", "?", "0", ":", "sin2", ")", ")", ";", "}", "}" ]
Returns the line's perpendicular distance from the argument, which can be a point, a line or a plane
[ "Returns", "the", "line", "s", "perpendicular", "distance", "from", "the", "argument", "which", "can", "be", "a", "point", "a", "line", "or", "a", "plane" ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js#L861-L881
27,073
sony/cdp-js
packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js
function(anchor, direction) { // Need to do this so that line's properties are not // references to the arguments passed in anchor = Vector.create(anchor); direction = Vector.create(direction); if (anchor.elements.length == 2) {anchor.elements.push(0); } if (direction.elements.length == 2) { direction.elements.push(0); } if (anchor.elements.length > 3 || direction.elements.length > 3) { return null; } var mod = direction.modulus(); if (mod === 0) { return null; } this.anchor = anchor; this.direction = Vector.create([ direction.elements[0] / mod, direction.elements[1] / mod, direction.elements[2] / mod ]); return this; }
javascript
function(anchor, direction) { // Need to do this so that line's properties are not // references to the arguments passed in anchor = Vector.create(anchor); direction = Vector.create(direction); if (anchor.elements.length == 2) {anchor.elements.push(0); } if (direction.elements.length == 2) { direction.elements.push(0); } if (anchor.elements.length > 3 || direction.elements.length > 3) { return null; } var mod = direction.modulus(); if (mod === 0) { return null; } this.anchor = anchor; this.direction = Vector.create([ direction.elements[0] / mod, direction.elements[1] / mod, direction.elements[2] / mod ]); return this; }
[ "function", "(", "anchor", ",", "direction", ")", "{", "// Need to do this so that line's properties are not", "// references to the arguments passed in", "anchor", "=", "Vector", ".", "create", "(", "anchor", ")", ";", "direction", "=", "Vector", ".", "create", "(", "direction", ")", ";", "if", "(", "anchor", ".", "elements", ".", "length", "==", "2", ")", "{", "anchor", ".", "elements", ".", "push", "(", "0", ")", ";", "}", "if", "(", "direction", ".", "elements", ".", "length", "==", "2", ")", "{", "direction", ".", "elements", ".", "push", "(", "0", ")", ";", "}", "if", "(", "anchor", ".", "elements", ".", "length", ">", "3", "||", "direction", ".", "elements", ".", "length", ">", "3", ")", "{", "return", "null", ";", "}", "var", "mod", "=", "direction", ".", "modulus", "(", ")", ";", "if", "(", "mod", "===", "0", ")", "{", "return", "null", ";", "}", "this", ".", "anchor", "=", "anchor", ";", "this", ".", "direction", "=", "Vector", ".", "create", "(", "[", "direction", ".", "elements", "[", "0", "]", "/", "mod", ",", "direction", ".", "elements", "[", "1", "]", "/", "mod", ",", "direction", ".", "elements", "[", "2", "]", "/", "mod", "]", ")", ";", "return", "this", ";", "}" ]
Set the line's anchor point and direction.
[ "Set", "the", "line", "s", "anchor", "point", "and", "direction", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cafeteria/app/external/sylvester/scripts/sylvester-0.1.3.js#L995-L1012
27,074
sony/cdp-js
packages/cdp-lazyload/src/scripts/cdp.lazyload.js
_getExtension
function _getExtension(file) { var ret; if (file) { var fileTypes = file.split("."); var len = fileTypes.length; if (0 === len) { return ret; } ret = fileTypes[len - 1]; return ret; } }
javascript
function _getExtension(file) { var ret; if (file) { var fileTypes = file.split("."); var len = fileTypes.length; if (0 === len) { return ret; } ret = fileTypes[len - 1]; return ret; } }
[ "function", "_getExtension", "(", "file", ")", "{", "var", "ret", ";", "if", "(", "file", ")", "{", "var", "fileTypes", "=", "file", ".", "split", "(", "\".\"", ")", ";", "var", "len", "=", "fileTypes", ".", "length", ";", "if", "(", "0", "===", "len", ")", "{", "return", "ret", ";", "}", "ret", "=", "fileTypes", "[", "len", "-", "1", "]", ";", "return", "ret", ";", "}", "}" ]
\~english Get file extension by file name. @private @param file {String} [in] file path / file name @return {String} file extension \~japanese ファイル名から拡張子を取得 @private @param file {String} [in] file path / file name @return {String} file extension
[ "\\", "~english", "Get", "file", "extension", "by", "file", "name", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-lazyload/src/scripts/cdp.lazyload.js#L30-L41
27,075
sony/cdp-js
packages/cdp-lazyload/src/scripts/cdp.lazyload.js
_getScriptElements
function _getScriptElements($typeLazy) { var scripts; var src = $typeLazy.attr("src"); if (!src) { src = $typeLazy.data("src"); } if ("js" === _getExtension(src).toLowerCase()) { return $typeLazy; } else { if (requirejs && typeof requirejs.toUrl === "function") { src = requirejs.toUrl(src); } $.ajax({ url: src, method: "GET", async: false, dataType: "html", success: function (data){ scripts = data; }, error: function (data, status) { console.error(TAG + "lazyLoad() ajax request failed. [status: " + status + "][src: " + src + "]"); } }); return $(scripts).find("script"); } }
javascript
function _getScriptElements($typeLazy) { var scripts; var src = $typeLazy.attr("src"); if (!src) { src = $typeLazy.data("src"); } if ("js" === _getExtension(src).toLowerCase()) { return $typeLazy; } else { if (requirejs && typeof requirejs.toUrl === "function") { src = requirejs.toUrl(src); } $.ajax({ url: src, method: "GET", async: false, dataType: "html", success: function (data){ scripts = data; }, error: function (data, status) { console.error(TAG + "lazyLoad() ajax request failed. [status: " + status + "][src: " + src + "]"); } }); return $(scripts).find("script"); } }
[ "function", "_getScriptElements", "(", "$typeLazy", ")", "{", "var", "scripts", ";", "var", "src", "=", "$typeLazy", ".", "attr", "(", "\"src\"", ")", ";", "if", "(", "!", "src", ")", "{", "src", "=", "$typeLazy", ".", "data", "(", "\"src\"", ")", ";", "}", "if", "(", "\"js\"", "===", "_getExtension", "(", "src", ")", ".", "toLowerCase", "(", ")", ")", "{", "return", "$typeLazy", ";", "}", "else", "{", "if", "(", "requirejs", "&&", "typeof", "requirejs", ".", "toUrl", "===", "\"function\"", ")", "{", "src", "=", "requirejs", ".", "toUrl", "(", "src", ")", ";", "}", "$", ".", "ajax", "(", "{", "url", ":", "src", ",", "method", ":", "\"GET\"", ",", "async", ":", "false", ",", "dataType", ":", "\"html\"", ",", "success", ":", "function", "(", "data", ")", "{", "scripts", "=", "data", ";", "}", ",", "error", ":", "function", "(", "data", ",", "status", ")", "{", "console", ".", "error", "(", "TAG", "+", "\"lazyLoad() ajax request failed. [status: \"", "+", "status", "+", "\"][src: \"", "+", "src", "+", "\"]\"", ")", ";", "}", "}", ")", ";", "return", "$", "(", "scripts", ")", ".", "find", "(", "\"script\"", ")", ";", "}", "}" ]
\~english Get script elements. @private @param file {jQuery} [in] type lazy elements @return {jQuery} script elements \~japanese script element の取得 @private @param file {jQuery} [in] type lazy elements @return {jQuery} script elements
[ "\\", "~english", "Get", "script", "elements", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-lazyload/src/scripts/cdp.lazyload.js#L58-L84
27,076
sony/cdp-js
packages/cdp-lazyload/src/scripts/cdp.lazyload.js
_appendSync
function _appendSync($script) { var _src = $script.attr("src"); if (!_src) { _src = $script.data("src"); } var _url = function ($elem) { var ret = _src; if (requirejs && typeof requirejs.toUrl === "function") { ret = requirejs.toUrl(ret); $elem.attr("src", ret); } return ret; }($script); var toLocation = function (url) { // 明示的に autoDomainAssign = false が指定されているときは、_src を返す if (false === Config.autoDomainAssign) { return _src; } else { var ret = url.split("?"); if (!ret || 0 === ret.length) { return url; } else { return ret[0]; } } }; var code; $.ajax({ url: _url, method: "GET", async: false, dataType: "text", success: function (data) { code = data; }, error: function (data, status) { console.error(TAG + "lazyLoad() ajax request failed. [status: " + status + "][src: " + _url + "]"); } }); if (code) { // sourceURL が指定されていなければ追加 if (!code.match(/\/\/@ sourceURL=[\s\S]*?\n/g) && !code.match(/\/\/# sourceURL=[\s\S]*?\n/g)) { code = code + "\n//# " + "sourceURL=" + toLocation(_url); } // script を有効化 $.globalEval(code); // <head> に <script> として追加 $script.attr("type", "false"); document.head.appendChild($script[0]); $script.removeAttr("type"); } }
javascript
function _appendSync($script) { var _src = $script.attr("src"); if (!_src) { _src = $script.data("src"); } var _url = function ($elem) { var ret = _src; if (requirejs && typeof requirejs.toUrl === "function") { ret = requirejs.toUrl(ret); $elem.attr("src", ret); } return ret; }($script); var toLocation = function (url) { // 明示的に autoDomainAssign = false が指定されているときは、_src を返す if (false === Config.autoDomainAssign) { return _src; } else { var ret = url.split("?"); if (!ret || 0 === ret.length) { return url; } else { return ret[0]; } } }; var code; $.ajax({ url: _url, method: "GET", async: false, dataType: "text", success: function (data) { code = data; }, error: function (data, status) { console.error(TAG + "lazyLoad() ajax request failed. [status: " + status + "][src: " + _url + "]"); } }); if (code) { // sourceURL が指定されていなければ追加 if (!code.match(/\/\/@ sourceURL=[\s\S]*?\n/g) && !code.match(/\/\/# sourceURL=[\s\S]*?\n/g)) { code = code + "\n//# " + "sourceURL=" + toLocation(_url); } // script を有効化 $.globalEval(code); // <head> に <script> として追加 $script.attr("type", "false"); document.head.appendChild($script[0]); $script.removeAttr("type"); } }
[ "function", "_appendSync", "(", "$script", ")", "{", "var", "_src", "=", "$script", ".", "attr", "(", "\"src\"", ")", ";", "if", "(", "!", "_src", ")", "{", "_src", "=", "$script", ".", "data", "(", "\"src\"", ")", ";", "}", "var", "_url", "=", "function", "(", "$elem", ")", "{", "var", "ret", "=", "_src", ";", "if", "(", "requirejs", "&&", "typeof", "requirejs", ".", "toUrl", "===", "\"function\"", ")", "{", "ret", "=", "requirejs", ".", "toUrl", "(", "ret", ")", ";", "$elem", ".", "attr", "(", "\"src\"", ",", "ret", ")", ";", "}", "return", "ret", ";", "}", "(", "$script", ")", ";", "var", "toLocation", "=", "function", "(", "url", ")", "{", "// 明示的に autoDomainAssign = false が指定されているときは、_src を返す", "if", "(", "false", "===", "Config", ".", "autoDomainAssign", ")", "{", "return", "_src", ";", "}", "else", "{", "var", "ret", "=", "url", ".", "split", "(", "\"?\"", ")", ";", "if", "(", "!", "ret", "||", "0", "===", "ret", ".", "length", ")", "{", "return", "url", ";", "}", "else", "{", "return", "ret", "[", "0", "]", ";", "}", "}", "}", ";", "var", "code", ";", "$", ".", "ajax", "(", "{", "url", ":", "_url", ",", "method", ":", "\"GET\"", ",", "async", ":", "false", ",", "dataType", ":", "\"text\"", ",", "success", ":", "function", "(", "data", ")", "{", "code", "=", "data", ";", "}", ",", "error", ":", "function", "(", "data", ",", "status", ")", "{", "console", ".", "error", "(", "TAG", "+", "\"lazyLoad() ajax request failed. [status: \"", "+", "status", "+", "\"][src: \"", "+", "_url", "+", "\"]\"", ")", ";", "}", "}", ")", ";", "if", "(", "code", ")", "{", "// sourceURL が指定されていなければ追加", "if", "(", "!", "code", ".", "match", "(", "/", "\\/\\/@ sourceURL=[\\s\\S]*?\\n", "/", "g", ")", "&&", "!", "code", ".", "match", "(", "/", "\\/\\/# sourceURL=[\\s\\S]*?\\n", "/", "g", ")", ")", "{", "code", "=", "code", "+", "\"\\n//# \"", "+", "\"sourceURL=\"", "+", "toLocation", "(", "_url", ")", ";", "}", "// script を有効化", "$", ".", "globalEval", "(", "code", ")", ";", "// <head> に <script> として追加", "$script", ".", "attr", "(", "\"type\"", ",", "\"false\"", ")", ";", "document", ".", "head", ".", "appendChild", "(", "$script", "[", "0", "]", ")", ";", "$script", ".", "removeAttr", "(", "\"type\"", ")", ";", "}", "}" ]
\~english Load script and append to head with "sourceURL". @param $script {JQuery} [in] script's jQuery object \~japanese "sourceURL" コメントと共に、script を同期読み込み jQuery.append() の Hack。 eval() でスクリプトを有効化している。 Developer Tool の Source Tree 上に表示するため、sourceURL が無ければ埋め込む @param $script {JQuery} [in] script の jQuery object
[ "\\", "~english", "Load", "script", "and", "append", "to", "head", "with", "sourceURL", "." ]
00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6
https://github.com/sony/cdp-js/blob/00e5ef7f2cb4addac61bfbee1fa2bc99e939e0b6/packages/cdp-lazyload/src/scripts/cdp.lazyload.js#L99-L158
27,077
npm/ndm
lib/service.js
Service
function Service(opts) { _.extend(this, { description: '', utils: require('./utils'), logger: require('./logger') }, require('./config')(), opts ); // scoped modules contain a '/' (@foo/bar). // this causes problems when generating logs/scripts // on some platforms. this.name = this.name.replace('/', '_'); // run the script within its ndm // node_modules directory. this.workingDirectory = this._workingDirectory(); this.logFile = this.utils.resolve( this.logsDirectory, this.name + '.log' ); this._copyFieldsFromPackageJson(); // try to grab some sane defaults from package.json. }
javascript
function Service(opts) { _.extend(this, { description: '', utils: require('./utils'), logger: require('./logger') }, require('./config')(), opts ); // scoped modules contain a '/' (@foo/bar). // this causes problems when generating logs/scripts // on some platforms. this.name = this.name.replace('/', '_'); // run the script within its ndm // node_modules directory. this.workingDirectory = this._workingDirectory(); this.logFile = this.utils.resolve( this.logsDirectory, this.name + '.log' ); this._copyFieldsFromPackageJson(); // try to grab some sane defaults from package.json. }
[ "function", "Service", "(", "opts", ")", "{", "_", ".", "extend", "(", "this", ",", "{", "description", ":", "''", ",", "utils", ":", "require", "(", "'./utils'", ")", ",", "logger", ":", "require", "(", "'./logger'", ")", "}", ",", "require", "(", "'./config'", ")", "(", ")", ",", "opts", ")", ";", "// scoped modules contain a '/' (@foo/bar).", "// this causes problems when generating logs/scripts", "// on some platforms.", "this", ".", "name", "=", "this", ".", "name", ".", "replace", "(", "'/'", ",", "'_'", ")", ";", "// run the script within its ndm", "// node_modules directory.", "this", ".", "workingDirectory", "=", "this", ".", "_workingDirectory", "(", ")", ";", "this", ".", "logFile", "=", "this", ".", "utils", ".", "resolve", "(", "this", ".", "logsDirectory", ",", "this", ".", "name", "+", "'.log'", ")", ";", "this", ".", "_copyFieldsFromPackageJson", "(", ")", ";", "// try to grab some sane defaults from package.json.", "}" ]
an OS-specific service wrapper for a Node.js process.
[ "an", "OS", "-", "specific", "service", "wrapper", "for", "a", "Node", ".", "js", "process", "." ]
0c5c50c409c365d5304bedc15754ddffa86aedbc
https://github.com/npm/ndm/blob/0c5c50c409c365d5304bedc15754ddffa86aedbc/lib/service.js#L9-L35
27,078
npm/ndm
lib/service.js
parseServiceJson
function parseServiceJson(serviceNameFilter, serviceJson) { var services = [], config = require('./config')(); Object.keys(serviceJson).forEach(function(serviceName) { if (serviceName === 'env' || serviceName === 'args') return; var serviceConfig = serviceJson[serviceName], processCount = serviceConfig.processes || 1; // if services have a process count > 1, // we'll create multiple run-scripts for them. _.range(processCount).forEach(function(i) { // apply sane defaults as we create // the services. var service = new Service(_.extend( { module: serviceName, name: i > 0 ? (serviceName + '-' + i) : serviceName }, serviceConfig )); // override env and args with global args and env. service.env = _.extend({}, dropInterviewQuestions(serviceJson.env), dropInterviewQuestions(serviceConfig.env) ); service.args = serviceConfig.args; if (_.isArray(serviceConfig.args)) { // combine arrays of arguments, if both top-level args. // and service-level args are an array. if (_.isArray(serviceJson.args)) service.args = [].concat(serviceJson.args, service.args); } else { // merge objects together if top-level, and service level // arguments are maps. service.args = _.extend({}, dropInterviewQuestions(serviceJson.args), dropInterviewQuestions(serviceConfig.args) ); } // we can optionaly filter to a specific service name. if (serviceNameFilter && service.name !== serviceNameFilter && !config.globalPackage) return; // replace placeholder variables // in the service.json. expandVariables(service, i); services.push(service); }); }); return services; }
javascript
function parseServiceJson(serviceNameFilter, serviceJson) { var services = [], config = require('./config')(); Object.keys(serviceJson).forEach(function(serviceName) { if (serviceName === 'env' || serviceName === 'args') return; var serviceConfig = serviceJson[serviceName], processCount = serviceConfig.processes || 1; // if services have a process count > 1, // we'll create multiple run-scripts for them. _.range(processCount).forEach(function(i) { // apply sane defaults as we create // the services. var service = new Service(_.extend( { module: serviceName, name: i > 0 ? (serviceName + '-' + i) : serviceName }, serviceConfig )); // override env and args with global args and env. service.env = _.extend({}, dropInterviewQuestions(serviceJson.env), dropInterviewQuestions(serviceConfig.env) ); service.args = serviceConfig.args; if (_.isArray(serviceConfig.args)) { // combine arrays of arguments, if both top-level args. // and service-level args are an array. if (_.isArray(serviceJson.args)) service.args = [].concat(serviceJson.args, service.args); } else { // merge objects together if top-level, and service level // arguments are maps. service.args = _.extend({}, dropInterviewQuestions(serviceJson.args), dropInterviewQuestions(serviceConfig.args) ); } // we can optionaly filter to a specific service name. if (serviceNameFilter && service.name !== serviceNameFilter && !config.globalPackage) return; // replace placeholder variables // in the service.json. expandVariables(service, i); services.push(service); }); }); return services; }
[ "function", "parseServiceJson", "(", "serviceNameFilter", ",", "serviceJson", ")", "{", "var", "services", "=", "[", "]", ",", "config", "=", "require", "(", "'./config'", ")", "(", ")", ";", "Object", ".", "keys", "(", "serviceJson", ")", ".", "forEach", "(", "function", "(", "serviceName", ")", "{", "if", "(", "serviceName", "===", "'env'", "||", "serviceName", "===", "'args'", ")", "return", ";", "var", "serviceConfig", "=", "serviceJson", "[", "serviceName", "]", ",", "processCount", "=", "serviceConfig", ".", "processes", "||", "1", ";", "// if services have a process count > 1,", "// we'll create multiple run-scripts for them.", "_", ".", "range", "(", "processCount", ")", ".", "forEach", "(", "function", "(", "i", ")", "{", "// apply sane defaults as we create", "// the services.", "var", "service", "=", "new", "Service", "(", "_", ".", "extend", "(", "{", "module", ":", "serviceName", ",", "name", ":", "i", ">", "0", "?", "(", "serviceName", "+", "'-'", "+", "i", ")", ":", "serviceName", "}", ",", "serviceConfig", ")", ")", ";", "// override env and args with global args and env.", "service", ".", "env", "=", "_", ".", "extend", "(", "{", "}", ",", "dropInterviewQuestions", "(", "serviceJson", ".", "env", ")", ",", "dropInterviewQuestions", "(", "serviceConfig", ".", "env", ")", ")", ";", "service", ".", "args", "=", "serviceConfig", ".", "args", ";", "if", "(", "_", ".", "isArray", "(", "serviceConfig", ".", "args", ")", ")", "{", "// combine arrays of arguments, if both top-level args.", "// and service-level args are an array.", "if", "(", "_", ".", "isArray", "(", "serviceJson", ".", "args", ")", ")", "service", ".", "args", "=", "[", "]", ".", "concat", "(", "serviceJson", ".", "args", ",", "service", ".", "args", ")", ";", "}", "else", "{", "// merge objects together if top-level, and service level", "// arguments are maps.", "service", ".", "args", "=", "_", ".", "extend", "(", "{", "}", ",", "dropInterviewQuestions", "(", "serviceJson", ".", "args", ")", ",", "dropInterviewQuestions", "(", "serviceConfig", ".", "args", ")", ")", ";", "}", "// we can optionaly filter to a specific service name.", "if", "(", "serviceNameFilter", "&&", "service", ".", "name", "!==", "serviceNameFilter", "&&", "!", "config", ".", "globalPackage", ")", "return", ";", "// replace placeholder variables", "// in the service.json.", "expandVariables", "(", "service", ",", "i", ")", ";", "services", ".", "push", "(", "service", ")", ";", "}", ")", ";", "}", ")", ";", "return", "services", ";", "}" ]
service.json files can be used to describe multiple services, they have a slightly different format than package.json.
[ "service", ".", "json", "files", "can", "be", "used", "to", "describe", "multiple", "services", "they", "have", "a", "slightly", "different", "format", "than", "package", ".", "json", "." ]
0c5c50c409c365d5304bedc15754ddffa86aedbc
https://github.com/npm/ndm/blob/0c5c50c409c365d5304bedc15754ddffa86aedbc/lib/service.js#L301-L358
27,079
cloudflare/json-schema-example-loader
lib/curl.js
function(uri, method, headers, data, encType) { var config = this.config; var flags = []; var str; method = method || 'GET'; if (data && method.toLowerCase() === 'get') { uri += this.buildQueryString(data); } str = ['curl', this.buildFlag('X', method.toUpperCase(), 0, ''), '"' + uri + '"'].join(' '); if (headers) { _.each(headers, function(val, header) { flags.push(this.buildFlag('H', header + config.HEADER_SEPARATOR + val, 5)); }, this); } if (data && method.toLowerCase() !== 'get') { if (encType === undefined || encType.match(this.formatter.jsonMediaType)) { flags.push(this.buildFlag('-data', this.formatData(data), 5, '\'')); } else if (encType === 'multipart/form-data') { flags.push(this.buildFlag('-form', this.formatForm(data), 5, '"')); } else { // The non-JSON, non-multipart data is a raw string. Do not format it. flags.push(this.buildFlag('-data', data)); } } if (flags.length) { return str + config.NEW_LINE + flags.join(config.NEW_LINE); } return str; }
javascript
function(uri, method, headers, data, encType) { var config = this.config; var flags = []; var str; method = method || 'GET'; if (data && method.toLowerCase() === 'get') { uri += this.buildQueryString(data); } str = ['curl', this.buildFlag('X', method.toUpperCase(), 0, ''), '"' + uri + '"'].join(' '); if (headers) { _.each(headers, function(val, header) { flags.push(this.buildFlag('H', header + config.HEADER_SEPARATOR + val, 5)); }, this); } if (data && method.toLowerCase() !== 'get') { if (encType === undefined || encType.match(this.formatter.jsonMediaType)) { flags.push(this.buildFlag('-data', this.formatData(data), 5, '\'')); } else if (encType === 'multipart/form-data') { flags.push(this.buildFlag('-form', this.formatForm(data), 5, '"')); } else { // The non-JSON, non-multipart data is a raw string. Do not format it. flags.push(this.buildFlag('-data', data)); } } if (flags.length) { return str + config.NEW_LINE + flags.join(config.NEW_LINE); } return str; }
[ "function", "(", "uri", ",", "method", ",", "headers", ",", "data", ",", "encType", ")", "{", "var", "config", "=", "this", ".", "config", ";", "var", "flags", "=", "[", "]", ";", "var", "str", ";", "method", "=", "method", "||", "'GET'", ";", "if", "(", "data", "&&", "method", ".", "toLowerCase", "(", ")", "===", "'get'", ")", "{", "uri", "+=", "this", ".", "buildQueryString", "(", "data", ")", ";", "}", "str", "=", "[", "'curl'", ",", "this", ".", "buildFlag", "(", "'X'", ",", "method", ".", "toUpperCase", "(", ")", ",", "0", ",", "''", ")", ",", "'\"'", "+", "uri", "+", "'\"'", "]", ".", "join", "(", "' '", ")", ";", "if", "(", "headers", ")", "{", "_", ".", "each", "(", "headers", ",", "function", "(", "val", ",", "header", ")", "{", "flags", ".", "push", "(", "this", ".", "buildFlag", "(", "'H'", ",", "header", "+", "config", ".", "HEADER_SEPARATOR", "+", "val", ",", "5", ")", ")", ";", "}", ",", "this", ")", ";", "}", "if", "(", "data", "&&", "method", ".", "toLowerCase", "(", ")", "!==", "'get'", ")", "{", "if", "(", "encType", "===", "undefined", "||", "encType", ".", "match", "(", "this", ".", "formatter", ".", "jsonMediaType", ")", ")", "{", "flags", ".", "push", "(", "this", ".", "buildFlag", "(", "'-data'", ",", "this", ".", "formatData", "(", "data", ")", ",", "5", ",", "'\\''", ")", ")", ";", "}", "else", "if", "(", "encType", "===", "'multipart/form-data'", ")", "{", "flags", ".", "push", "(", "this", ".", "buildFlag", "(", "'-form'", ",", "this", ".", "formatForm", "(", "data", ")", ",", "5", ",", "'\"'", ")", ")", ";", "}", "else", "{", "// The non-JSON, non-multipart data is a raw string. Do not format it.", "flags", ".", "push", "(", "this", ".", "buildFlag", "(", "'-data'", ",", "data", ")", ")", ";", "}", "}", "if", "(", "flags", ".", "length", ")", "{", "return", "str", "+", "config", ".", "NEW_LINE", "+", "flags", ".", "join", "(", "config", ".", "NEW_LINE", ")", ";", "}", "return", "str", ";", "}" ]
Build a cURL string @param {String} uri @param {String} [method=GET] @param {Object} [headers] @param {Object|Array} [data] @param {String} [encType=undefined] @returns {String}
[ "Build", "a", "cURL", "string" ]
cc3bba87a4990a229cbb2bd52d8159fc0bb4088b
https://github.com/cloudflare/json-schema-example-loader/blob/cc3bba87a4990a229cbb2bd52d8159fc0bb4088b/lib/curl.js#L24-L58
27,080
insin/react-heatpack
webpack.config.js
findNodeModules
function findNodeModules(cwd) { var parts = cwd.split(path.sep) while (parts.length > 0) { var target = path.join(parts.join(path.sep), 'node_modules') if (fs.existsSync(target)) { return target } parts.pop() } }
javascript
function findNodeModules(cwd) { var parts = cwd.split(path.sep) while (parts.length > 0) { var target = path.join(parts.join(path.sep), 'node_modules') if (fs.existsSync(target)) { return target } parts.pop() } }
[ "function", "findNodeModules", "(", "cwd", ")", "{", "var", "parts", "=", "cwd", ".", "split", "(", "path", ".", "sep", ")", "while", "(", "parts", ".", "length", ">", "0", ")", "{", "var", "target", "=", "path", ".", "join", "(", "parts", ".", "join", "(", "path", ".", "sep", ")", ",", "'node_modules'", ")", "if", "(", "fs", ".", "existsSync", "(", "target", ")", ")", "{", "return", "target", "}", "parts", ".", "pop", "(", ")", "}", "}" ]
Find the node_modules directory which will be resolved from a given dir.
[ "Find", "the", "node_modules", "directory", "which", "will", "be", "resolved", "from", "a", "given", "dir", "." ]
e862e92d39b7e89fc43c7e9c857bcef8f3fd6912
https://github.com/insin/react-heatpack/blob/e862e92d39b7e89fc43c7e9c857bcef8f3fd6912/webpack.config.js#L14-L23
27,081
xpl/useless
base/component.js
function () { Meta.globalTag ('dummy') $assertEveryCalled (function (mkay1, mkay2) { var this_ = undefined var Trait = $trait ({ somethingHappened: $trigger () }) var Other = $trait ({ somethingHappened: $dummy (function (_42) { $assert (this, this_); $assert (_42, 42); mkay1 () }) }) var Compo = $component ({ $traits: [Trait, Other], somethingHappened: function (_42) { $assert (this, this_); $assert (_42, 42); mkay2 () } }) this_ = new Compo () this_.somethingHappened (42) }) }
javascript
function () { Meta.globalTag ('dummy') $assertEveryCalled (function (mkay1, mkay2) { var this_ = undefined var Trait = $trait ({ somethingHappened: $trigger () }) var Other = $trait ({ somethingHappened: $dummy (function (_42) { $assert (this, this_); $assert (_42, 42); mkay1 () }) }) var Compo = $component ({ $traits: [Trait, Other], somethingHappened: function (_42) { $assert (this, this_); $assert (_42, 42); mkay2 () } }) this_ = new Compo () this_.somethingHappened (42) }) }
[ "function", "(", ")", "{", "Meta", ".", "globalTag", "(", "'dummy'", ")", "$assertEveryCalled", "(", "function", "(", "mkay1", ",", "mkay2", ")", "{", "var", "this_", "=", "undefined", "var", "Trait", "=", "$trait", "(", "{", "somethingHappened", ":", "$trigger", "(", ")", "}", ")", "var", "Other", "=", "$trait", "(", "{", "somethingHappened", ":", "$dummy", "(", "function", "(", "_42", ")", "{", "$assert", "(", "this", ",", "this_", ")", ";", "$assert", "(", "_42", ",", "42", ")", ";", "mkay1", "(", ")", "}", ")", "}", ")", "var", "Compo", "=", "$component", "(", "{", "$traits", ":", "[", "Trait", ",", "Other", "]", ",", "somethingHappened", ":", "function", "(", "_42", ")", "{", "$assert", "(", "this", ",", "this_", ")", ";", "$assert", "(", "_42", ",", "42", ")", ";", "mkay2", "(", ")", "}", "}", ")", "this_", "=", "new", "Compo", "(", ")", "this_", ".", "somethingHappened", "(", "42", ")", "}", ")", "}" ]
supply POD value from property accessor
[ "supply", "POD", "value", "from", "property", "accessor" ]
f44dcaff5ea6bfa817c1807b4ba29a1aadf5e40d
https://github.com/xpl/useless/blob/f44dcaff5ea6bfa817c1807b4ba29a1aadf5e40d/base/component.js#L367-L384
27,082
mikolalysenko/game-shell
shell.js
tryFullscreen
function tryFullscreen(shell) { //Request full screen var elem = shell.element if(shell._wantFullscreen && !shell._fullscreenActive) { var fs = elem.requestFullscreen || elem.requestFullScreen || elem.webkitRequestFullscreen || elem.webkitRequestFullScreen || elem.mozRequestFullscreen || elem.mozRequestFullScreen || function() {} fs.call(elem) } if(shell._wantPointerLock && !shell._pointerLockActive) { var pl = elem.requestPointerLock || elem.webkitRequestPointerLock || elem.mozRequestPointerLock || elem.msRequestPointerLock || elem.oRequestPointerLock || function() {} pl.call(elem) } }
javascript
function tryFullscreen(shell) { //Request full screen var elem = shell.element if(shell._wantFullscreen && !shell._fullscreenActive) { var fs = elem.requestFullscreen || elem.requestFullScreen || elem.webkitRequestFullscreen || elem.webkitRequestFullScreen || elem.mozRequestFullscreen || elem.mozRequestFullScreen || function() {} fs.call(elem) } if(shell._wantPointerLock && !shell._pointerLockActive) { var pl = elem.requestPointerLock || elem.webkitRequestPointerLock || elem.mozRequestPointerLock || elem.msRequestPointerLock || elem.oRequestPointerLock || function() {} pl.call(elem) } }
[ "function", "tryFullscreen", "(", "shell", ")", "{", "//Request full screen", "var", "elem", "=", "shell", ".", "element", "if", "(", "shell", ".", "_wantFullscreen", "&&", "!", "shell", ".", "_fullscreenActive", ")", "{", "var", "fs", "=", "elem", ".", "requestFullscreen", "||", "elem", ".", "requestFullScreen", "||", "elem", ".", "webkitRequestFullscreen", "||", "elem", ".", "webkitRequestFullScreen", "||", "elem", ".", "mozRequestFullscreen", "||", "elem", ".", "mozRequestFullScreen", "||", "function", "(", ")", "{", "}", "fs", ".", "call", "(", "elem", ")", "}", "if", "(", "shell", ".", "_wantPointerLock", "&&", "!", "shell", ".", "_pointerLockActive", ")", "{", "var", "pl", "=", "elem", ".", "requestPointerLock", "||", "elem", ".", "webkitRequestPointerLock", "||", "elem", ".", "mozRequestPointerLock", "||", "elem", ".", "msRequestPointerLock", "||", "elem", ".", "oRequestPointerLock", "||", "function", "(", ")", "{", "}", "pl", ".", "call", "(", "elem", ")", "}", "}" ]
Fullscreen state toggle
[ "Fullscreen", "state", "toggle" ]
74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9
https://github.com/mikolalysenko/game-shell/blob/74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9/shell.js#L236-L259
27,083
mikolalysenko/game-shell
shell.js
setKeyState
function setKeyState(shell, key, state) { var ps = shell._curKeyState[key] if(ps !== state) { if(state) { shell._pressCount[key]++ } else { shell._releaseCount[key]++ } shell._curKeyState[key] = state } }
javascript
function setKeyState(shell, key, state) { var ps = shell._curKeyState[key] if(ps !== state) { if(state) { shell._pressCount[key]++ } else { shell._releaseCount[key]++ } shell._curKeyState[key] = state } }
[ "function", "setKeyState", "(", "shell", ",", "key", ",", "state", ")", "{", "var", "ps", "=", "shell", ".", "_curKeyState", "[", "key", "]", "if", "(", "ps", "!==", "state", ")", "{", "if", "(", "state", ")", "{", "shell", ".", "_pressCount", "[", "key", "]", "++", "}", "else", "{", "shell", ".", "_releaseCount", "[", "key", "]", "++", "}", "shell", ".", "_curKeyState", "[", "key", "]", "=", "state", "}", "}" ]
Set key state
[ "Set", "key", "state" ]
74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9
https://github.com/mikolalysenko/game-shell/blob/74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9/shell.js#L348-L358
27,084
mikolalysenko/game-shell
shell.js
tick
function tick(shell) { var skip = hrtime() + shell.frameSkip , pCount = shell._pressCount , rCount = shell._releaseCount , i, s, t , tr = shell._tickRate , n = keyNames.length while(!shell._paused && hrtime() >= shell._lastTick + tr) { //Skip frames if we are over budget if(hrtime() > skip) { shell._lastTick = hrtime() + tr return } //Tick the game s = hrtime() shell.emit("tick") t = hrtime() shell.tickTime = t - s //Update counters and time ++shell.tickCount shell._lastTick += tr //Shift input state for(i=0; i<n; ++i) { pCount[i] = rCount[i] = 0 } if(shell._pointerLockActive) { shell.prevMouseX = shell.mouseX = shell.width>>1 shell.prevMouseY = shell.mouseY = shell.height>>1 } else { shell.prevMouseX = shell.mouseX shell.prevMouseY = shell.mouseY } shell.scroll[0] = shell.scroll[1] = shell.scroll[2] = 0 } }
javascript
function tick(shell) { var skip = hrtime() + shell.frameSkip , pCount = shell._pressCount , rCount = shell._releaseCount , i, s, t , tr = shell._tickRate , n = keyNames.length while(!shell._paused && hrtime() >= shell._lastTick + tr) { //Skip frames if we are over budget if(hrtime() > skip) { shell._lastTick = hrtime() + tr return } //Tick the game s = hrtime() shell.emit("tick") t = hrtime() shell.tickTime = t - s //Update counters and time ++shell.tickCount shell._lastTick += tr //Shift input state for(i=0; i<n; ++i) { pCount[i] = rCount[i] = 0 } if(shell._pointerLockActive) { shell.prevMouseX = shell.mouseX = shell.width>>1 shell.prevMouseY = shell.mouseY = shell.height>>1 } else { shell.prevMouseX = shell.mouseX shell.prevMouseY = shell.mouseY } shell.scroll[0] = shell.scroll[1] = shell.scroll[2] = 0 } }
[ "function", "tick", "(", "shell", ")", "{", "var", "skip", "=", "hrtime", "(", ")", "+", "shell", ".", "frameSkip", ",", "pCount", "=", "shell", ".", "_pressCount", ",", "rCount", "=", "shell", ".", "_releaseCount", ",", "i", ",", "s", ",", "t", ",", "tr", "=", "shell", ".", "_tickRate", ",", "n", "=", "keyNames", ".", "length", "while", "(", "!", "shell", ".", "_paused", "&&", "hrtime", "(", ")", ">=", "shell", ".", "_lastTick", "+", "tr", ")", "{", "//Skip frames if we are over budget", "if", "(", "hrtime", "(", ")", ">", "skip", ")", "{", "shell", ".", "_lastTick", "=", "hrtime", "(", ")", "+", "tr", "return", "}", "//Tick the game", "s", "=", "hrtime", "(", ")", "shell", ".", "emit", "(", "\"tick\"", ")", "t", "=", "hrtime", "(", ")", "shell", ".", "tickTime", "=", "t", "-", "s", "//Update counters and time", "++", "shell", ".", "tickCount", "shell", ".", "_lastTick", "+=", "tr", "//Shift input state", "for", "(", "i", "=", "0", ";", "i", "<", "n", ";", "++", "i", ")", "{", "pCount", "[", "i", "]", "=", "rCount", "[", "i", "]", "=", "0", "}", "if", "(", "shell", ".", "_pointerLockActive", ")", "{", "shell", ".", "prevMouseX", "=", "shell", ".", "mouseX", "=", "shell", ".", "width", ">>", "1", "shell", ".", "prevMouseY", "=", "shell", ".", "mouseY", "=", "shell", ".", "height", ">>", "1", "}", "else", "{", "shell", ".", "prevMouseX", "=", "shell", ".", "mouseX", "shell", ".", "prevMouseY", "=", "shell", ".", "mouseY", "}", "shell", ".", "scroll", "[", "0", "]", "=", "shell", ".", "scroll", "[", "1", "]", "=", "shell", ".", "scroll", "[", "2", "]", "=", "0", "}", "}" ]
Ticks the game state one update
[ "Ticks", "the", "game", "state", "one", "update" ]
74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9
https://github.com/mikolalysenko/game-shell/blob/74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9/shell.js#L368-L407
27,085
mikolalysenko/game-shell
shell.js
handleKeyUp
function handleKeyUp(shell, ev) { handleEvent(shell, ev) var kc = physicalKeyCode(ev.keyCode || ev.char || ev.which || ev.charCode) if(kc >= 0) { setKeyState(shell, kc, false) } }
javascript
function handleKeyUp(shell, ev) { handleEvent(shell, ev) var kc = physicalKeyCode(ev.keyCode || ev.char || ev.which || ev.charCode) if(kc >= 0) { setKeyState(shell, kc, false) } }
[ "function", "handleKeyUp", "(", "shell", ",", "ev", ")", "{", "handleEvent", "(", "shell", ",", "ev", ")", "var", "kc", "=", "physicalKeyCode", "(", "ev", ".", "keyCode", "||", "ev", ".", "char", "||", "ev", ".", "which", "||", "ev", ".", "charCode", ")", "if", "(", "kc", ">=", "0", ")", "{", "setKeyState", "(", "shell", ",", "kc", ",", "false", ")", "}", "}" ]
Set key up
[ "Set", "key", "up" ]
74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9
https://github.com/mikolalysenko/game-shell/blob/74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9/shell.js#L447-L453
27,086
mikolalysenko/game-shell
shell.js
handleKeyDown
function handleKeyDown(shell, ev) { if(!isFocused(shell)) { return } handleEvent(shell, ev) if(ev.metaKey) { //Hack: Clear key state when meta gets pressed to prevent keys sticking handleBlur(shell, ev) } else { var kc = physicalKeyCode(ev.keyCode || ev.char || ev.which || ev.charCode) if(kc >= 0) { setKeyState(shell, kc, true) } } }
javascript
function handleKeyDown(shell, ev) { if(!isFocused(shell)) { return } handleEvent(shell, ev) if(ev.metaKey) { //Hack: Clear key state when meta gets pressed to prevent keys sticking handleBlur(shell, ev) } else { var kc = physicalKeyCode(ev.keyCode || ev.char || ev.which || ev.charCode) if(kc >= 0) { setKeyState(shell, kc, true) } } }
[ "function", "handleKeyDown", "(", "shell", ",", "ev", ")", "{", "if", "(", "!", "isFocused", "(", "shell", ")", ")", "{", "return", "}", "handleEvent", "(", "shell", ",", "ev", ")", "if", "(", "ev", ".", "metaKey", ")", "{", "//Hack: Clear key state when meta gets pressed to prevent keys sticking", "handleBlur", "(", "shell", ",", "ev", ")", "}", "else", "{", "var", "kc", "=", "physicalKeyCode", "(", "ev", ".", "keyCode", "||", "ev", ".", "char", "||", "ev", ".", "which", "||", "ev", ".", "charCode", ")", "if", "(", "kc", ">=", "0", ")", "{", "setKeyState", "(", "shell", ",", "kc", ",", "true", ")", "}", "}", "}" ]
Set key down
[ "Set", "key", "down" ]
74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9
https://github.com/mikolalysenko/game-shell/blob/74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9/shell.js#L456-L470
27,087
mikolalysenko/game-shell
shell.js
handleMouseWheel
function handleMouseWheel(shell, ev) { handleEvent(shell, ev) var scale = 1 switch(ev.deltaMode) { case 0: //Pixel scale = 1 break case 1: //Line scale = 12 break case 2: //Page scale = shell.height break } //Add scroll shell.scroll[0] += ev.deltaX * scale shell.scroll[1] += ev.deltaY * scale shell.scroll[2] += (ev.deltaZ * scale)||0.0 return false }
javascript
function handleMouseWheel(shell, ev) { handleEvent(shell, ev) var scale = 1 switch(ev.deltaMode) { case 0: //Pixel scale = 1 break case 1: //Line scale = 12 break case 2: //Page scale = shell.height break } //Add scroll shell.scroll[0] += ev.deltaX * scale shell.scroll[1] += ev.deltaY * scale shell.scroll[2] += (ev.deltaZ * scale)||0.0 return false }
[ "function", "handleMouseWheel", "(", "shell", ",", "ev", ")", "{", "handleEvent", "(", "shell", ",", "ev", ")", "var", "scale", "=", "1", "switch", "(", "ev", ".", "deltaMode", ")", "{", "case", "0", ":", "//Pixel", "scale", "=", "1", "break", "case", "1", ":", "//Line", "scale", "=", "12", "break", "case", "2", ":", "//Page", "scale", "=", "shell", ".", "height", "break", "}", "//Add scroll", "shell", ".", "scroll", "[", "0", "]", "+=", "ev", ".", "deltaX", "*", "scale", "shell", ".", "scroll", "[", "1", "]", "+=", "ev", ".", "deltaY", "*", "scale", "shell", ".", "scroll", "[", "2", "]", "+=", "(", "ev", ".", "deltaZ", "*", "scale", ")", "||", "0.0", "return", "false", "}" ]
Handle mouse wheel events
[ "Handle", "mouse", "wheel", "events" ]
74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9
https://github.com/mikolalysenko/game-shell/blob/74b81aabc1750c6c3d5e73a5566b4b9ca2032fb9/shell.js#L534-L553
27,088
cloudflare/json-schema-example-loader
lib/pointer.js
createPointerEvaluator
function createPointerEvaluator(target) { // Use cache to store already received values. var cache = {}; return function(pointer) { if (!isValidJSONPointer(pointer)) { // If it's not, an exception will be thrown. throw new ReferenceError(ErrorMessage.INVALID_POINTER); } // First, look up in the cache. if (cache.hasOwnProperty(pointer)) { // If cache entry exists, return it's value. return cache[pointer]; } // Now, when all arguments are valid, we can start evaluation. // First of all, let's convert JSON pointer string to tokens list. var tokensList = parsePointer(pointer); var token; var value = target; // Evaluation will be continued till tokens list is not empty // and returned value is not an undefined. while (!_.isUndefined(value) && !_.isUndefined(token = tokensList.pop())) { // Evaluate the token in current context. // `getValue()` might throw an exception, but we won't handle it. value = getValue(value, token); } // Pointer evaluation is done, save value in the cache and return it. cache[pointer] = value; return value; }; }
javascript
function createPointerEvaluator(target) { // Use cache to store already received values. var cache = {}; return function(pointer) { if (!isValidJSONPointer(pointer)) { // If it's not, an exception will be thrown. throw new ReferenceError(ErrorMessage.INVALID_POINTER); } // First, look up in the cache. if (cache.hasOwnProperty(pointer)) { // If cache entry exists, return it's value. return cache[pointer]; } // Now, when all arguments are valid, we can start evaluation. // First of all, let's convert JSON pointer string to tokens list. var tokensList = parsePointer(pointer); var token; var value = target; // Evaluation will be continued till tokens list is not empty // and returned value is not an undefined. while (!_.isUndefined(value) && !_.isUndefined(token = tokensList.pop())) { // Evaluate the token in current context. // `getValue()` might throw an exception, but we won't handle it. value = getValue(value, token); } // Pointer evaluation is done, save value in the cache and return it. cache[pointer] = value; return value; }; }
[ "function", "createPointerEvaluator", "(", "target", ")", "{", "// Use cache to store already received values.", "var", "cache", "=", "{", "}", ";", "return", "function", "(", "pointer", ")", "{", "if", "(", "!", "isValidJSONPointer", "(", "pointer", ")", ")", "{", "// If it's not, an exception will be thrown.", "throw", "new", "ReferenceError", "(", "ErrorMessage", ".", "INVALID_POINTER", ")", ";", "}", "// First, look up in the cache.", "if", "(", "cache", ".", "hasOwnProperty", "(", "pointer", ")", ")", "{", "// If cache entry exists, return it's value.", "return", "cache", "[", "pointer", "]", ";", "}", "// Now, when all arguments are valid, we can start evaluation.", "// First of all, let's convert JSON pointer string to tokens list.", "var", "tokensList", "=", "parsePointer", "(", "pointer", ")", ";", "var", "token", ";", "var", "value", "=", "target", ";", "// Evaluation will be continued till tokens list is not empty", "// and returned value is not an undefined.", "while", "(", "!", "_", ".", "isUndefined", "(", "value", ")", "&&", "!", "_", ".", "isUndefined", "(", "token", "=", "tokensList", ".", "pop", "(", ")", ")", ")", "{", "// Evaluate the token in current context.", "// `getValue()` might throw an exception, but we won't handle it.", "value", "=", "getValue", "(", "value", ",", "token", ")", ";", "}", "// Pointer evaluation is done, save value in the cache and return it.", "cache", "[", "pointer", "]", "=", "value", ";", "return", "value", ";", "}", ";", "}" ]
Returns function that takes JSON Pointer as single argument and evaluates it in given |target| context. Returned function throws an exception if pointer is not valid or any error occurs during evaluation. @param {Object} target Evaluation target. @returns {Function}
[ "Returns", "function", "that", "takes", "JSON", "Pointer", "as", "single", "argument", "and", "evaluates", "it", "in", "given", "|target|", "context", ".", "Returned", "function", "throws", "an", "exception", "if", "pointer", "is", "not", "valid", "or", "any", "error", "occurs", "during", "evaluation", "." ]
cc3bba87a4990a229cbb2bd52d8159fc0bb4088b
https://github.com/cloudflare/json-schema-example-loader/blob/cc3bba87a4990a229cbb2bd52d8159fc0bb4088b/lib/pointer.js#L42-L76
27,089
cloudflare/json-schema-example-loader
lib/pointer.js
isValidJSONPointer
function isValidJSONPointer(pointer) { if (!_.isString(pointer)) { // If it's not a string, it obviously is not valid. return false; } // If it is string and is an empty string, it's valid. if ('' === pointer) { return true; } // If it is non-empty string, it must match spec defined format. // Check Section 3 of specification for concrete syntax. return validPointerRegex.test(pointer); }
javascript
function isValidJSONPointer(pointer) { if (!_.isString(pointer)) { // If it's not a string, it obviously is not valid. return false; } // If it is string and is an empty string, it's valid. if ('' === pointer) { return true; } // If it is non-empty string, it must match spec defined format. // Check Section 3 of specification for concrete syntax. return validPointerRegex.test(pointer); }
[ "function", "isValidJSONPointer", "(", "pointer", ")", "{", "if", "(", "!", "_", ".", "isString", "(", "pointer", ")", ")", "{", "// If it's not a string, it obviously is not valid.", "return", "false", ";", "}", "// If it is string and is an empty string, it's valid.", "if", "(", "''", "===", "pointer", ")", "{", "return", "true", ";", "}", "// If it is non-empty string, it must match spec defined format.", "// Check Section 3 of specification for concrete syntax.", "return", "validPointerRegex", ".", "test", "(", "pointer", ")", ";", "}" ]
Validates JSON pointer string. @param pointer @returns {boolean}
[ "Validates", "JSON", "pointer", "string", "." ]
cc3bba87a4990a229cbb2bd52d8159fc0bb4088b
https://github.com/cloudflare/json-schema-example-loader/blob/cc3bba87a4990a229cbb2bd52d8159fc0bb4088b/lib/pointer.js#L85-L99
27,090
cloudflare/json-schema-example-loader
lib/pointer.js
getPointedValue
function getPointedValue(target, pointer) { // If not object, an exception will be thrown. if (!_.isPlainObject(target)) { throw new ReferenceError(ErrorMessage.INVALID_DOCUMENT_TYPE); } // target is already parsed, create an evaluator for it. var evaluator = createPointerEvaluator(target); // If no pointer was provided, return evaluator function. if (_.isUndefined(pointer)) { return evaluator; } else { return evaluator(pointer); } }
javascript
function getPointedValue(target, pointer) { // If not object, an exception will be thrown. if (!_.isPlainObject(target)) { throw new ReferenceError(ErrorMessage.INVALID_DOCUMENT_TYPE); } // target is already parsed, create an evaluator for it. var evaluator = createPointerEvaluator(target); // If no pointer was provided, return evaluator function. if (_.isUndefined(pointer)) { return evaluator; } else { return evaluator(pointer); } }
[ "function", "getPointedValue", "(", "target", ",", "pointer", ")", "{", "// If not object, an exception will be thrown.", "if", "(", "!", "_", ".", "isPlainObject", "(", "target", ")", ")", "{", "throw", "new", "ReferenceError", "(", "ErrorMessage", ".", "INVALID_DOCUMENT_TYPE", ")", ";", "}", "// target is already parsed, create an evaluator for it.", "var", "evaluator", "=", "createPointerEvaluator", "(", "target", ")", ";", "// If no pointer was provided, return evaluator function.", "if", "(", "_", ".", "isUndefined", "(", "pointer", ")", ")", "{", "return", "evaluator", ";", "}", "else", "{", "return", "evaluator", "(", "pointer", ")", ";", "}", "}" ]
Returns target object's value pointed by pointer, returns undefined if |pointer| points to non-existing value. If pointer is not provided, validates first argument and returns evaluator function that takes pointer as argument. @param {Object} target @param {string} [pointer] @returns {*} pointer JSON Pointer string
[ "Returns", "target", "object", "s", "value", "pointed", "by", "pointer", "returns", "undefined", "if", "|pointer|", "points", "to", "non", "-", "existing", "value", ".", "If", "pointer", "is", "not", "provided", "validates", "first", "argument", "and", "returns", "evaluator", "function", "that", "takes", "pointer", "as", "argument", "." ]
cc3bba87a4990a229cbb2bd52d8159fc0bb4088b
https://github.com/cloudflare/json-schema-example-loader/blob/cc3bba87a4990a229cbb2bd52d8159fc0bb4088b/lib/pointer.js#L204-L219
27,091
jstransformers/inputformat-to-jstransformer
build.js
finishedInstall
function finishedInstall(err) { if (err) { throw new Error(err) } const dictionary = {} for (const i in list) { if (list[i]) { const name = list[i] const transformer = require('jstransformer-' + name) // eslint-disable-line import/no-dynamic-require const formats = transformer.inputFormats || [name] for (const n in formats) { if (formats[n]) { const format = formats[n] // Ensure the input format exists in the dictionary. if (!dictionary[format]) { dictionary[format] = [] } // Add the package to the input format. dictionary[format].push('jstransformer-' + name) } } } } const sorted = sortJson(dictionary) fs.writeFileSync('dictionary.json', JSON.stringify(sorted, null, 2)) }
javascript
function finishedInstall(err) { if (err) { throw new Error(err) } const dictionary = {} for (const i in list) { if (list[i]) { const name = list[i] const transformer = require('jstransformer-' + name) // eslint-disable-line import/no-dynamic-require const formats = transformer.inputFormats || [name] for (const n in formats) { if (formats[n]) { const format = formats[n] // Ensure the input format exists in the dictionary. if (!dictionary[format]) { dictionary[format] = [] } // Add the package to the input format. dictionary[format].push('jstransformer-' + name) } } } } const sorted = sortJson(dictionary) fs.writeFileSync('dictionary.json', JSON.stringify(sorted, null, 2)) }
[ "function", "finishedInstall", "(", "err", ")", "{", "if", "(", "err", ")", "{", "throw", "new", "Error", "(", "err", ")", "}", "const", "dictionary", "=", "{", "}", "for", "(", "const", "i", "in", "list", ")", "{", "if", "(", "list", "[", "i", "]", ")", "{", "const", "name", "=", "list", "[", "i", "]", "const", "transformer", "=", "require", "(", "'jstransformer-'", "+", "name", ")", "// eslint-disable-line import/no-dynamic-require", "const", "formats", "=", "transformer", ".", "inputFormats", "||", "[", "name", "]", "for", "(", "const", "n", "in", "formats", ")", "{", "if", "(", "formats", "[", "n", "]", ")", "{", "const", "format", "=", "formats", "[", "n", "]", "// Ensure the input format exists in the dictionary.", "if", "(", "!", "dictionary", "[", "format", "]", ")", "{", "dictionary", "[", "format", "]", "=", "[", "]", "}", "// Add the package to the input format.", "dictionary", "[", "format", "]", ".", "push", "(", "'jstransformer-'", "+", "name", ")", "}", "}", "}", "}", "const", "sorted", "=", "sortJson", "(", "dictionary", ")", "fs", ".", "writeFileSync", "(", "'dictionary.json'", ",", "JSON", ".", "stringify", "(", "sorted", ",", "null", ",", "2", ")", ")", "}" ]
Write the dictionary.json based on the installed modules. @param {string} err The error that was reported.
[ "Write", "the", "dictionary", ".", "json", "based", "on", "the", "installed", "modules", "." ]
6e962561524f0bff7911d64f4be07dbc345800bf
https://github.com/jstransformers/inputformat-to-jstransformer/blob/6e962561524f0bff7911d64f4be07dbc345800bf/build.js#L34-L61
27,092
koa-modules/swig
index.js
setFilters
function setFilters(swig, filters) { for (var name in filters) { swig.setFilter(name, filters[name]); } }
javascript
function setFilters(swig, filters) { for (var name in filters) { swig.setFilter(name, filters[name]); } }
[ "function", "setFilters", "(", "swig", ",", "filters", ")", "{", "for", "(", "var", "name", "in", "filters", ")", "{", "swig", ".", "setFilter", "(", "name", ",", "filters", "[", "name", "]", ")", ";", "}", "}" ]
Add filters for Swig
[ "Add", "filters", "for", "Swig" ]
bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb
https://github.com/koa-modules/swig/blob/bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb/index.js#L146-L150
27,093
koa-modules/swig
index.js
setTags
function setTags(swig, tags) { var name, tag; for (name in tags) { tag = tags[name]; swig.setTag(name, tag.parse, tag.compile, tag.ends, tag.blockLevel); } }
javascript
function setTags(swig, tags) { var name, tag; for (name in tags) { tag = tags[name]; swig.setTag(name, tag.parse, tag.compile, tag.ends, tag.blockLevel); } }
[ "function", "setTags", "(", "swig", ",", "tags", ")", "{", "var", "name", ",", "tag", ";", "for", "(", "name", "in", "tags", ")", "{", "tag", "=", "tags", "[", "name", "]", ";", "swig", ".", "setTag", "(", "name", ",", "tag", ".", "parse", ",", "tag", ".", "compile", ",", "tag", ".", "ends", ",", "tag", ".", "blockLevel", ")", ";", "}", "}" ]
Add tags for Swig
[ "Add", "tags", "for", "Swig" ]
bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb
https://github.com/koa-modules/swig/blob/bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb/index.js#L156-L162
27,094
koa-modules/swig
index.js
setExtensions
function setExtensions(swig, extensions) { for (var name in extensions) { swig.setExtension(name, extensions[name]); } }
javascript
function setExtensions(swig, extensions) { for (var name in extensions) { swig.setExtension(name, extensions[name]); } }
[ "function", "setExtensions", "(", "swig", ",", "extensions", ")", "{", "for", "(", "var", "name", "in", "extensions", ")", "{", "swig", ".", "setExtension", "(", "name", ",", "extensions", "[", "name", "]", ")", ";", "}", "}" ]
Add extensions for Swig
[ "Add", "extensions", "for", "Swig" ]
bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb
https://github.com/koa-modules/swig/blob/bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb/index.js#L168-L174
27,095
stefanullinger/grunt-twig-render
Gruntfile.js
function (token, context, chain) { var // Parse the output without any filter unfiltered = Twig.parse.apply(this, [token.output, context]), // A regular expression to find closing and opening tags with spaces between them rBetweenTagSpaces = />\s+</g, // Replace all space between closing and opening html tags output = unfiltered.replace(rBetweenTagSpaces,'><').trim(); return { chain: chain, output: output }; }
javascript
function (token, context, chain) { var // Parse the output without any filter unfiltered = Twig.parse.apply(this, [token.output, context]), // A regular expression to find closing and opening tags with spaces between them rBetweenTagSpaces = />\s+</g, // Replace all space between closing and opening html tags output = unfiltered.replace(rBetweenTagSpaces,'><').trim(); return { chain: chain, output: output }; }
[ "function", "(", "token", ",", "context", ",", "chain", ")", "{", "var", "// Parse the output without any filter", "unfiltered", "=", "Twig", ".", "parse", ".", "apply", "(", "this", ",", "[", "token", ".", "output", ",", "context", "]", ")", ",", "// A regular expression to find closing and opening tags with spaces between them", "rBetweenTagSpaces", "=", "/", ">\\s+<", "/", "g", ",", "// Replace all space between closing and opening html tags", "output", "=", "unfiltered", ".", "replace", "(", "rBetweenTagSpaces", ",", "'><'", ")", ".", "trim", "(", ")", ";", "return", "{", "chain", ":", "chain", ",", "output", ":", "output", "}", ";", "}" ]
Parse the html and return it without any spaces between tags
[ "Parse", "the", "html", "and", "return", "it", "without", "any", "spaces", "between", "tags" ]
407c1f68026a27801af5445d8c254eb23967094f
https://github.com/stefanullinger/grunt-twig-render/blob/407c1f68026a27801af5445d8c254eb23967094f/Gruntfile.js#L231-L242
27,096
dannygarcia/grunt-jekyll
tasks/jekyll.js
configContext
function configContext (next) { if (options.raw) { // Tmp file is only available within the context of this function tmp.file({ prefix: '_config.', postfix: '.yml' }, function (err, path, fd) { rawConfigFile = path; if (err) { grunt.fail.warn(err); } // Write raw to file fs.writeSync(fd, new Buffer(options.raw), 0, options.raw.length); next(); }); } else { next(); } }
javascript
function configContext (next) { if (options.raw) { // Tmp file is only available within the context of this function tmp.file({ prefix: '_config.', postfix: '.yml' }, function (err, path, fd) { rawConfigFile = path; if (err) { grunt.fail.warn(err); } // Write raw to file fs.writeSync(fd, new Buffer(options.raw), 0, options.raw.length); next(); }); } else { next(); } }
[ "function", "configContext", "(", "next", ")", "{", "if", "(", "options", ".", "raw", ")", "{", "// Tmp file is only available within the context of this function", "tmp", ".", "file", "(", "{", "prefix", ":", "'_config.'", ",", "postfix", ":", "'.yml'", "}", ",", "function", "(", "err", ",", "path", ",", "fd", ")", "{", "rawConfigFile", "=", "path", ";", "if", "(", "err", ")", "{", "grunt", ".", "fail", ".", "warn", "(", "err", ")", ";", "}", "// Write raw to file", "fs", ".", "writeSync", "(", "fd", ",", "new", "Buffer", "(", "options", ".", "raw", ")", ",", "0", ",", "options", ".", "raw", ".", "length", ")", ";", "next", "(", ")", ";", "}", ")", ";", "}", "else", "{", "next", "(", ")", ";", "}", "}" ]
Create temporary config file if needed
[ "Create", "temporary", "config", "file", "if", "needed" ]
24009febfb119fc4468710bab462f64f388b030a
https://github.com/dannygarcia/grunt-jekyll/blob/24009febfb119fc4468710bab462f64f388b030a/tasks/jekyll.js#L73-L92
27,097
filamentgroup/grunticon-lib
static/grunticon.embed.js
function(stylesheet, refresh){ if( icons && !refresh ){ return icons; } icons = {}; // get grunticon stylesheet by its href var svgss, rules, cssText, iconClass, iconSVGEncoded, iconSVGRaw; svgss = stylesheet.sheet; if( !svgss ){ return icons; } rules = svgss.cssRules ? svgss.cssRules : svgss.rules; for( var i = 0; i < rules.length; i++ ){ cssText = rules[ i ].cssText; iconClass = selectorPlaceholder + rules[ i ].selectorText; iconSVGEncoded = cssText.split( ");" )[ 0 ].match( /US\-ASCII\,([^"']+)/ ); if( iconSVGEncoded && iconSVGEncoded[ 1 ] ){ iconSVGRaw = decodeURIComponent( iconSVGEncoded[ 1 ] ); icons[ iconClass ] = iconSVGRaw; } } return icons; }
javascript
function(stylesheet, refresh){ if( icons && !refresh ){ return icons; } icons = {}; // get grunticon stylesheet by its href var svgss, rules, cssText, iconClass, iconSVGEncoded, iconSVGRaw; svgss = stylesheet.sheet; if( !svgss ){ return icons; } rules = svgss.cssRules ? svgss.cssRules : svgss.rules; for( var i = 0; i < rules.length; i++ ){ cssText = rules[ i ].cssText; iconClass = selectorPlaceholder + rules[ i ].selectorText; iconSVGEncoded = cssText.split( ");" )[ 0 ].match( /US\-ASCII\,([^"']+)/ ); if( iconSVGEncoded && iconSVGEncoded[ 1 ] ){ iconSVGRaw = decodeURIComponent( iconSVGEncoded[ 1 ] ); icons[ iconClass ] = iconSVGRaw; } } return icons; }
[ "function", "(", "stylesheet", ",", "refresh", ")", "{", "if", "(", "icons", "&&", "!", "refresh", ")", "{", "return", "icons", ";", "}", "icons", "=", "{", "}", ";", "// get grunticon stylesheet by its href", "var", "svgss", ",", "rules", ",", "cssText", ",", "iconClass", ",", "iconSVGEncoded", ",", "iconSVGRaw", ";", "svgss", "=", "stylesheet", ".", "sheet", ";", "if", "(", "!", "svgss", ")", "{", "return", "icons", ";", "}", "rules", "=", "svgss", ".", "cssRules", "?", "svgss", ".", "cssRules", ":", "svgss", ".", "rules", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "rules", ".", "length", ";", "i", "++", ")", "{", "cssText", "=", "rules", "[", "i", "]", ".", "cssText", ";", "iconClass", "=", "selectorPlaceholder", "+", "rules", "[", "i", "]", ".", "selectorText", ";", "iconSVGEncoded", "=", "cssText", ".", "split", "(", "\");\"", ")", "[", "0", "]", ".", "match", "(", "/", "US\\-ASCII\\,([^\"']+)", "/", ")", ";", "if", "(", "iconSVGEncoded", "&&", "iconSVGEncoded", "[", "1", "]", ")", "{", "iconSVGRaw", "=", "decodeURIComponent", "(", "iconSVGEncoded", "[", "1", "]", ")", ";", "icons", "[", "iconClass", "]", "=", "iconSVGRaw", ";", "}", "}", "return", "icons", ";", "}" ]
this function can rip the svg markup from the css so we can embed it anywhere
[ "this", "function", "can", "rip", "the", "svg", "markup", "from", "the", "css", "so", "we", "can", "embed", "it", "anywhere" ]
2b7ecfe54a19a8d2429996cb456c7dd4ce04d71f
https://github.com/filamentgroup/grunticon-lib/blob/2b7ecfe54a19a8d2429996cb456c7dd4ce04d71f/static/grunticon.embed.js#L31-L59
27,098
tunnckoCoreLabs/get-installed-path
src/index.js
getInstalledPathSync
function getInstalledPathSync (name, opts) { if (!isValidString(name)) { throw new TypeError('get-installed-path: expect `name` to be string') } const filePaths = defaults(name, opts) const firstPath = filePaths[0] const modulePath = filePaths.find((filePath) => { let stat = null try { stat = fs.statSync(filePath) } catch (e) { return false } if (stat.isDirectory()) { return true } const msg = `Possibly "${name}" is not a directory: ${filePath}` throw new Error('get-installed-path: some error occured! ' + msg) }) if (!modulePath) { const label = 'get-installed-path:' const msg = `${label} module not found "${name}" in path ${firstPath}` throw new Error(msg) } return modulePath }
javascript
function getInstalledPathSync (name, opts) { if (!isValidString(name)) { throw new TypeError('get-installed-path: expect `name` to be string') } const filePaths = defaults(name, opts) const firstPath = filePaths[0] const modulePath = filePaths.find((filePath) => { let stat = null try { stat = fs.statSync(filePath) } catch (e) { return false } if (stat.isDirectory()) { return true } const msg = `Possibly "${name}" is not a directory: ${filePath}` throw new Error('get-installed-path: some error occured! ' + msg) }) if (!modulePath) { const label = 'get-installed-path:' const msg = `${label} module not found "${name}" in path ${firstPath}` throw new Error(msg) } return modulePath }
[ "function", "getInstalledPathSync", "(", "name", ",", "opts", ")", "{", "if", "(", "!", "isValidString", "(", "name", ")", ")", "{", "throw", "new", "TypeError", "(", "'get-installed-path: expect `name` to be string'", ")", "}", "const", "filePaths", "=", "defaults", "(", "name", ",", "opts", ")", "const", "firstPath", "=", "filePaths", "[", "0", "]", "const", "modulePath", "=", "filePaths", ".", "find", "(", "(", "filePath", ")", "=>", "{", "let", "stat", "=", "null", "try", "{", "stat", "=", "fs", ".", "statSync", "(", "filePath", ")", "}", "catch", "(", "e", ")", "{", "return", "false", "}", "if", "(", "stat", ".", "isDirectory", "(", ")", ")", "{", "return", "true", "}", "const", "msg", "=", "`", "${", "name", "}", "${", "filePath", "}", "`", "throw", "new", "Error", "(", "'get-installed-path: some error occured! '", "+", "msg", ")", "}", ")", "if", "(", "!", "modulePath", ")", "{", "const", "label", "=", "'get-installed-path:'", "const", "msg", "=", "`", "${", "label", "}", "${", "name", "}", "${", "firstPath", "}", "`", "throw", "new", "Error", "(", "msg", ")", "}", "return", "modulePath", "}" ]
> Get installed path of a `name` package synchronous. Returns `boolean` when `paths` option is used and filepath is directory, otherwise returns a full filepath OR throws error. @example const { getInstalledPathSync } = require('get-installed-path') const npmPath = getInstalledPathSync('npm') console.log(npmPath) // => '/home/charlike/.nvm/path/to/lib/node_modules/npm' const gmPath = getInstalledPathSync('global-modules', { local: true }) console.log(gmPath) // => '~/code/get-installed-path/node_modules/global-modules' @param {string} name package name @param {Object} opts pass `opts.local` to check locally @return {string} The full filepath or throw `TypeError` if `name` not a string or is empty string @name getInstalledPathSync @public
[ ">", "Get", "installed", "path", "of", "a", "name", "package", "synchronous", ".", "Returns", "boolean", "when", "paths", "option", "is", "used", "and", "filepath", "is", "directory", "otherwise", "returns", "a", "full", "filepath", "OR", "throws", "error", "." ]
e71687df4e972ee98bc8d1d4fe3d13e5f3a750f9
https://github.com/tunnckoCoreLabs/get-installed-path/blob/e71687df4e972ee98bc8d1d4fe3d13e5f3a750f9/src/index.js#L123-L154
27,099
bpmn-io/drag-tabs
index.js
DragTabs
function DragTabs($el, options) { // we are an event emitter assign(this, createEmitter()); this.options = options || {}; this.$el = $el; this._moveTab = bind(this._moveTab, this); this._onDragstart = bind(this._onDragstart, this); this._onDragend = bind(this._onDragend, this); this._onDrop = bind(this._onDrop, this); this._init(); this.update(); }
javascript
function DragTabs($el, options) { // we are an event emitter assign(this, createEmitter()); this.options = options || {}; this.$el = $el; this._moveTab = bind(this._moveTab, this); this._onDragstart = bind(this._onDragstart, this); this._onDragend = bind(this._onDragend, this); this._onDrop = bind(this._onDrop, this); this._init(); this.update(); }
[ "function", "DragTabs", "(", "$el", ",", "options", ")", "{", "// we are an event emitter", "assign", "(", "this", ",", "createEmitter", "(", ")", ")", ";", "this", ".", "options", "=", "options", "||", "{", "}", ";", "this", ".", "$el", "=", "$el", ";", "this", ".", "_moveTab", "=", "bind", "(", "this", ".", "_moveTab", ",", "this", ")", ";", "this", ".", "_onDragstart", "=", "bind", "(", "this", ".", "_onDragstart", ",", "this", ")", ";", "this", ".", "_onDragend", "=", "bind", "(", "this", ".", "_onDragend", ",", "this", ")", ";", "this", ".", "_onDrop", "=", "bind", "(", "this", ".", "_onDrop", ",", "this", ")", ";", "this", ".", "_init", "(", ")", ";", "this", ".", "update", "(", ")", ";", "}" ]
This component provides the infrastructure needed to move tabs around by dragging. It's not this component's responsibility to the actual moving of the tab, but exposing an event based interface that communicates when and where the tab dragging should happen. It makes sure all the tabs inside the intended container are draggable, ignoring the ones that are declared as so. The component is an event emitter and it emits the following events: - 'drag' is fired everytime there is a new position - 'end' is always fired at the end of the drag - 'cancel' is only fired when the dragging is canceled The three events are emitted with the following context: ```js var context = { dragTab: {HTMLElement}, newIndex: {Number} }; ``` @example: (1) provide a tabs-container: var $el = ( <div> <ul class="my-tabs-container"> <li class="my-tab"></li> <li class="my-tab"></li> <li class="my-tab ignore-me"></li> </ul> </div> ); (2) initialize dragTabs: var dragger = dragTabs(tabBarNode, { selectors: { tabsContainer: '.my-tabs-container', tab: '.my-tab', ignore: '.ignore-me' } }); (3) listen to the drag event: dragger.on('drag', function(context) { var dragTab = context.dragTab, newIndex = context.newIndex; // tab dragging logic }); (4) update the dragger if tabs change and or the tab container resizes: dragger.update(); @param {DOMElement} el @param {Object} options @param {Object} options.selectors @param {String} options.selectors.tabsContainer the container all tabs are contained in @param {String} options.selectors.tab a single tab inside the tab container @param {String} options.selectors.ignore tabs that should be ignored during scroll left/right @param {String} [options.showPreview=true] whether to show or hide the drag preview
[ "This", "component", "provides", "the", "infrastructure", "needed", "to", "move", "tabs", "around", "by", "dragging", "." ]
ce9299b969c0d2ed1eaa38195bb002a12a12873a
https://github.com/bpmn-io/drag-tabs/blob/ce9299b969c0d2ed1eaa38195bb002a12a12873a/index.js#L93-L109