Input: ### . respondTo ( method ) [CODESPLIT] function respondTo ( method , msg ) { if ( msg ) flag ( this , 'message' , msg ) ; var obj = flag ( this , 'object' ) , itself = flag ( this , 'itself' ) , context = ( 'function' === _ . type ( obj ) && ! itself ) ? obj . prototype [ method ] : obj [ method ] ; this . assert ( 'function' === typeof context , 'expected #{this} to respond to ' + _ . inspect ( method ) , 'expected #{this} to not respond to ' + _ . inspect ( method ) ) ; }


Input: ### . change ( function ) [CODESPLIT] function assertChanges ( object , prop , msg ) { if ( msg ) flag ( this , 'message' , msg ) ; var fn = flag ( this , 'object' ) ; new Assertion ( object , msg ) . to . have . property ( prop ) ; new Assertion ( fn ) . is . a ( 'function' ) ; var initial = object [ prop ] ; fn ( ) ; this . assert ( initial !== object [ prop ] , 'expected .' + prop + ' to change' , 'expected .' + prop + ' to not change' ) ; }


Input: explicitly define this method as function as to have it s name to include as ssfi [CODESPLIT] function shouldGetter ( ) { if ( this instanceof String || this instanceof Number || this instanceof Boolean ) { return new Assertion ( this . valueOf ( ) , null , shouldGetter ) ; } return new Assertion ( this , null , shouldGetter ) ; }


Input: Returns true if the given function throws the given value when invoked . The value may be : [CODESPLIT] function functionThrows ( fn , context , args , value ) { try { fn . apply ( context , args ) ; } catch ( error ) { if ( value == null ) return true ; if ( _isFunction2 [ 'default' ] ( value ) && error instanceof value ) return true ; var message = error . message || error ; if ( typeof message === 'string' ) { if ( _isRegexp2 [ 'default' ] ( value ) && value . test ( error . message ) ) return true ; if ( typeof value === 'string' && message . indexOf ( value ) !== - 1 ) return true ; } } return false ; }


Input: Returns true if the given object is an instanceof value or its typeof is the given value . [CODESPLIT] function isA ( object , value ) { if ( _isFunction2 [ 'default' ] ( value ) ) return object instanceof value ; if ( value === 'array' ) return Array . isArray ( object ) ; return typeof object === value ; }


Input: add all options to the default command [CODESPLIT] function ( bin , opt ) { cmd = bin ; if ( opt . testing !== 'undefined' ) { opt . dryRun = opt . testing ; } if ( typeof opt . testSuite === 'undefined' ) { opt . testSuite = '' ; } if ( typeof opt . verbose === 'undefined' ) { opt . verbose = '' ; } if ( typeof opt . dryRun === 'undefined' ) { opt . dryRun = false ; } if ( typeof opt . silent === 'undefined' ) { opt . silent = false ; } if ( typeof opt . testing === 'undefined' ) { opt . testing = false ; } if ( typeof opt . debug === 'undefined' ) { opt . debug = false ; } if ( typeof opt . testClass === 'undefined' ) { opt . testClass = '' ; } if ( typeof opt . clear === 'undefined' ) { opt . clear = false ; } if ( typeof opt . flags === 'undefined' ) { opt . flags = '' ; } if ( typeof opt . notify === 'undefined' ) { opt . notify = false ; } if ( typeof opt . noInteraction === 'undefined' ) { opt . noInteraction = true ; } if ( typeof opt . noAnsi === 'undefined' ) { opt . noAnsi = false ; } if ( typeof opt . quiet === 'undefined' ) { opt . quiet = false ; } if ( typeof opt . formatter === 'undefined' ) { opt . formatter = '' ; } cmd = opt . clear ? 'clear && ' + cmd : cmd ; // assign default class and/or test suite if ( opt . testSuite ) { cmd += ' ' + opt . testSuite ; } if ( opt . testClass ) { cmd += ' ' + opt . testClass ; } if ( opt . verbose ) { cmd += ' -' + opt . verbose ; } if ( opt . formatter ) { cmd += ' -f' + opt . formatter ; } if ( opt . quiet ) { cmd += ' --quiet' ; } if ( opt . noInteraction ) { cmd += ' --no-interaction' ; } cmd += opt . noAnsi ? ' --no-ansi' : ' --ansi' ; cmd += ' ' + opt . flags ; cmd . trim ( ) ; // clean up any lingering space remnants return cmd ; }


Input: how many arguments should we consume based on the nargs option? [CODESPLIT] function eatNargs ( i , key , args ) { var toEat = checkAllAliases ( key , opts . narg ) if ( args . length - ( i + 1 ) < toEat ) error = Error ( __ ( 'Not enough arguments following: %s' , key ) ) for ( var ii = i + 1 ; ii < ( toEat + i + 1 ) ; ii ++ ) { setArg ( key , args [ ii ] ) } return ( i + toEat ) }


Input: if an option is an array eat all non - hyphenated arguments following it ... YUM! e . g . -- foo apple banana cat becomes [ apple banana cat ] [CODESPLIT] function eatArray ( i , key , args ) { for ( var ii = i + 1 ; ii < args . length ; ii ++ ) { if ( / ^- / . test ( args [ ii ] ) ) break i = ii setArg ( key , args [ ii ] ) } return i }


Input: set args from config . json file this should be applied last so that defaults can be applied . [CODESPLIT] function setConfig ( argv ) { var configLookup = { } // expand defaults/aliases, in-case any happen to reference // the config.json file. applyDefaultsAndAliases ( configLookup , aliases , defaults ) Object . keys ( flags . configs ) . forEach ( function ( configKey ) { var configPath = argv [ configKey ] || configLookup [ configKey ] if ( configPath ) { try { var config = require ( path . resolve ( process . cwd ( ) , configPath ) ) Object . keys ( config ) . forEach ( function ( key ) { // setting arguments via CLI takes precedence over // values within the config file. if ( argv [ key ] === undefined || ( flags . defaulted [ key ] ) ) { delete argv [ key ] setArg ( key , config [ key ] ) } } ) } catch ( ex ) { if ( argv [ configKey ] ) error = Error ( __ ( 'Invalid JSON config file: %s' , configPath ) ) } } } ) }


Input: extend the aliases list with inferred aliases . [CODESPLIT] function extendAliases ( obj ) { Object . keys ( obj || { } ) . forEach ( function ( key ) { aliases [ key ] = [ ] . concat ( opts . alias [ key ] || [ ] ) // For "--option-name", also set argv.optionName aliases [ key ] . concat ( key ) . forEach ( function ( x ) { if ( / - / . test ( x ) ) { var c = camelCase ( x ) aliases [ key ] . push ( c ) newAliases [ c ] = true } } ) aliases [ key ] . forEach ( function ( x ) { aliases [ x ] = [ key ] . concat ( aliases [ key ] . filter ( function ( y ) { return x !== y } ) ) } ) } ) }


Input: check if a flag is set for any of a key s aliases . [CODESPLIT] function checkAllAliases ( key , flag ) { var isSet = false var toCheck = [ ] . concat ( aliases [ key ] || [ ] , key ) toCheck . forEach ( function ( key ) { if ( flag [ key ] ) isSet = flag [ key ] } ) return isSet }


Input: given a flag enforce a default type . [CODESPLIT] function guessType ( key , flags ) { var type = 'boolean' if ( flags . strings && flags . strings [ key ] ) type = 'string' else if ( flags . arrays && flags . arrays [ key ] ) type = 'array' return type }


Input: return the maximum width of a string in the left - hand column of a table . [CODESPLIT] function maxWidth ( table ) { var width = 0 // table might be of the form [leftColumn], // or {key: leftColumn}} if ( ! Array . isArray ( table ) ) { table = Object . keys ( table ) . map ( function ( key ) { return [ table [ key ] ] } ) } table . forEach ( function ( v ) { width = Math . max ( v [ 0 ] . length , width ) } ) // if we've enabled 'wrap' we should limit // the max-width of the left-column. if ( wrap ) width = Math . min ( width , parseInt ( wrap * 0.5 , 10 ) ) return width }


Input: make sure any options set for aliases are copied to the keys being aliased . [CODESPLIT] function normalizeAliases ( ) { var demanded = yargs . getDemanded ( ) var options = yargs . getOptions ( ) ; ( Object . keys ( options . alias ) || [ ] ) . forEach ( function ( key ) { options . alias [ key ] . forEach ( function ( alias ) { // copy descriptions. if ( descriptions [ alias ] ) self . describe ( key , descriptions [ alias ] ) // copy demanded. if ( demanded [ alias ] ) yargs . demand ( key , demanded [ alias ] . msg ) // type messages. if ( ~ options . boolean . indexOf ( alias ) ) yargs . boolean ( key ) if ( ~ options . count . indexOf ( alias ) ) yargs . count ( key ) if ( ~ options . string . indexOf ( alias ) ) yargs . string ( key ) if ( ~ options . normalize . indexOf ( alias ) ) yargs . normalize ( key ) if ( ~ options . array . indexOf ( alias ) ) yargs . array ( key ) } ) } ) }


Input: format the default - value - string displayed in the right - hand column . [CODESPLIT] function defaultString ( value , defaultDescription ) { var string = '[' + __ ( 'default:' ) + ' ' if ( value === undefined && ! defaultDescription ) return null if ( defaultDescription ) { string += defaultDescription } else { switch ( typeof value ) { case 'string' : string += JSON . stringify ( value ) break case 'object' : string += JSON . stringify ( value ) break default : string += value } } return string + ']' }


Input: / * Hack an instance of Argv with process . argv into Argv so people can do require ( yargs ) ( [ -- beeble = 1 - z zizzle ] ) . argv to parse a list of args and require ( yargs ) . argv to get a parsed version of process . argv . [CODESPLIT] function sigletonify ( inst ) { Object . keys ( inst ) . forEach ( function ( key ) { if ( key === 'argv' ) { Argv . __defineGetter__ ( key , inst . __lookupGetter__ ( key ) ) } else { Argv [ key ] = typeof inst [ key ] === 'function' ? inst [ key ] . bind ( inst ) : inst [ key ] } } ) }


Input: find the value form with the given name in the attribute forms otherwise undefined [CODESPLIT] function find_attr_value ( attrForms , attrName ) { var attrVal ; var attrPos = - 1 ; if ( attrForms && Array . isArray ( attrForms ) ) { attrKey = attrForms . find ( function ( form , i ) { attrPos = i ; return ( i % 2 === 1 ) && form . value === attrName ; } ) if ( attrKey && attrPos + 1 < attrForms . length ) { attrVal = attrForms [ attrPos + 1 ] ; } } return attrVal ; }


Input: Get s user s passports if not on DAO [CODESPLIT] function ( options ) { options = options || { } if ( this . passports && this . passports . every ( t => t instanceof app . orm [ 'Passport' ] ) && options . reload !== true ) { return Promise . resolve ( this ) } else { return this . getPassports ( { transaction : options . transaction || null } ) . then ( passports => { passports = passports || [ ] this . passports = passports this . setDataValue ( 'passports' , passports ) this . set ( 'passports' , passports ) return this } ) } }


Input: Proxy to { @link Ext . Base#override } . Please refer { @link Ext . Base#override } for further details . [CODESPLIT] function ( cls , overrides ) { if ( cls . $isClass ) { return cls . override ( overrides ) ; } else { Ext . apply ( cls . prototype , overrides ) ; } }


Input: Returns the type of the given variable in string format . List of possible values are : [CODESPLIT] function ( value ) { if ( value === null ) { return 'null' ; } var type = typeof value ; if ( type === 'undefined' || type === 'string' || type === 'number' || type === 'boolean' ) { return type ; } var typeToString = toString . call ( value ) ; switch ( typeToString ) { case '[object Array]' : return 'array' ; case '[object Date]' : return 'date' ; case '[object Boolean]' : return 'boolean' ; case '[object Number]' : return 'number' ; case '[object RegExp]' : return 'regexp' ; } if ( type === 'function' ) { return 'function' ; } if ( type === 'object' ) { if ( value . nodeType !== undefined ) { if ( value . nodeType === 3 ) { return ( / \S / ) . test ( value . nodeValue ) ? 'textnode' : 'whitespace' ; } else { return 'element' ; } } return 'object' ; } //<debug error> Ext . Error . raise ( { sourceClass : 'Ext' , sourceMethod : 'typeOf' , msg : 'Failed to determine the type of the specified value "' + value + '". This is most likely a bug.' } ) ; //</debug> }


Input: echo str > path . [CODESPLIT] function write ( path , str ) { fs . writeFileSync ( path , str ) ; console . log ( terminal . cyan ( pad ( 'create : ' ) ) + path ) ; }


Input: mkdir - p [CODESPLIT] function mkdir ( path , silent ) { if ( ! exists ( path ) ) { fs . mkdirSync ( path , 0755 ) ; if ( ! silent ) console . log ( terminal . cyan ( pad ( 'create : ' ) ) + path ) ; } }


Input: Tests if path is empty . [CODESPLIT] function isEmptyDirectory ( path ) { var files ; try { files = fs . readdirSync ( path ) ; if ( files . length > 0 ) { return false ; } } catch ( err ) { if ( err . code ) { terminal . abort ( 'Error: ' , err ) ; } else { throw e ; } } return true ; }


Input: of the storage scheme JCM include the epoch of the clock here? [CODESPLIT] function ( config , callback , scope ) { // Ext . data . utilities . check ( 'DatabaseDefinition' , 'constructor' , 'config' , config , [ 'key' , 'database_name' , 'generation' , 'system_name' , 'replica_number' ] ) ; // this . set ( config ) ; config . config_id = 'definition' ; Ext . data . DatabaseDefinition . superclass . constructor . call ( this , config ) ; }


Input: Gets the target for the event . Unlike { @link #target } this returns the main element for your event . So if you are listening to a tap event on Ext . Viewport . element and you tap on an inner element of Ext . Viewport . element this will return Ext . Viewport . element . [CODESPLIT] function ( selector , maxDepth , returnEl ) { if ( arguments . length === 0 ) { return this . delegatedTarget ; } return selector ? Ext . fly ( this . target ) . findParent ( selector , maxDepth , returnEl ) : ( returnEl ? Ext . get ( this . target ) : this . target ) ; }


Input: Adds an { [CODESPLIT] function ( action , silent ) { action = Ext . factory ( action , Ext . app . Action ) ; this . getActions ( ) . push ( action ) ; var url = action . getUrl ( ) ; if ( this . getUpdateUrl ( ) ) { // history.pushState({}, action.getTitle(), "#" + action.getUrl()); this . setToken ( url ) ; window . location . hash = url ; } if ( silent !== true ) { this . fireEvent ( 'change' , url ) ; } this . setToken ( url ) ; }


Input: Navigate to the previous active action . This changes the page url . [CODESPLIT] function ( ) { var actions = this . getActions ( ) , previousAction = actions [ actions . length - 2 ] ; if ( previousAction ) { actions . pop ( ) ; previousAction . getController ( ) . getApplication ( ) . redirectTo ( previousAction . getUrl ( ) ) ; } else { actions [ actions . length - 1 ] . getController ( ) . getApplication ( ) . redirectTo ( '' ) ; } }


Input: Format a string by replacing all keys between { and } with values from the given dictionary [CODESPLIT] function strformat ( string , dict ) { var formatted = string ; for ( var prop in dict ) { var regexp = new RegExp ( '\\{' + prop + '\\}' , 'gi' ) ; formatted = formatted . replace ( regexp , dict [ prop ] ) ; } return formatted ; }


Input: Creates a new instance of the GrelRequest class . [CODESPLIT] function GrelRequest ( grel ) { var authString ; if ( grel . token ) { authString = grel . token + ':' ; } else { authString = grel . user + ':' + grel . password ; } this . headers = { 'Authorization' : 'Basic ' + new Buffer ( authString ) . toString ( 'base64' ) , 'Accept' : 'application/vnd.github.manifold-preview' , 'User-Agent' : 'Grel' } ; this . grel = grel ; this . content = null ; }


Input: Private method that handles HTTP responses we get from GitHub . This method will always be executed in the context of a GrelRequest . [CODESPLIT] function handleResponse ( res , data , callback ) { // HTTP 204 doesn't have a response var json = data && JSON . parse ( data ) || { } ; if ( ( res . statusCode >= 200 ) && ( res . statusCode <= 206 ) ) { // Handle a few known responses switch ( json . message ) { case 'Bad credentials' : callback . call ( this , json ) ; break ; default : callback . call ( this , null , json ) ; } } else { callback . call ( this , json ) ; } }


Input: split markdown header [CODESPLIT] function splitHeader ( content ) { // New line characters need to handle all operating systems. const lines = content . split ( / \r?\n / ) ; if ( lines [ 0 ] !== '---' ) { return { } ; } let i = 1 ; for ( ; i < lines . length - 1 ; ++ i ) { if ( lines [ i ] === '---' ) { break ; } } return { header : lines . slice ( 1 , i + 1 ) . join ( '\n' ) , content : lines . slice ( i + 1 ) . join ( '\n' ) , } ; }


Input: Scrolls to the given location . [CODESPLIT] function ( x , y , animation ) { if ( this . isDestroyed ) { return this ; } //<deprecated product=touch since=2.0> if ( typeof x != 'number' && arguments . length === 1 ) { //<debug warn> Ext . Logger . deprecate ( "Calling scrollTo() with an object argument is deprecated, " + "please pass x and y arguments instead" , this ) ; //</debug> y = x . y ; x = x . x ; } //</deprecated> var translatable = this . getTranslatable ( ) , position = this . position , positionChanged = false , translationX , translationY ; if ( this . isAxisEnabled ( 'x' ) ) { if ( isNaN ( x ) || typeof x != 'number' ) { x = position . x ; } else { if ( position . x !== x ) { position . x = x ; positionChanged = true ; } } translationX = - x ; } if ( this . isAxisEnabled ( 'y' ) ) { if ( isNaN ( y ) || typeof y != 'number' ) { y = position . y ; } else { if ( position . y !== y ) { position . y = y ; positionChanged = true ; } } translationY = - y ; } if ( positionChanged ) { if ( animation !== undefined && animation !== false ) { translatable . translateAnimated ( translationX , translationY , animation ) ; } else { this . fireEvent ( 'scroll' , this , position . x , position . y ) ; translatable . translate ( translationX , translationY ) ; } } return this ; }


Input: Scrolls to the end of the scrollable view . [CODESPLIT] function ( animation ) { var size = this . getSize ( ) , cntSize = this . getContainerSize ( ) ; return this . scrollTo ( size . x - cntSize . x , size . y - cntSize . y , animation ) ; }


Input: Change the scroll offset by the given amount . [CODESPLIT] function ( x , y , animation ) { var position = this . position ; x = ( typeof x == 'number' ) ? x + position . x : null ; y = ( typeof y == 'number' ) ? y + position . y : null ; return this . scrollTo ( x , y , animation ) ; }


Input: Creates new Draggable . [CODESPLIT] function ( config ) { var element ; this . extraConstraint = { } ; this . initialConfig = config ; this . offset = { x : 0 , y : 0 } ; this . listeners = { dragstart : 'onDragStart' , drag : 'onDrag' , dragend : 'onDragEnd' , resize : 'onElementResize' , touchstart : 'onPress' , touchend : 'onRelease' , scope : this } ; if ( config && config . element ) { element = config . element ; delete config . element ; this . setElement ( element ) ; } return this ; }


Input: addActions - add actions util [CODESPLIT] function addActions ( actions ) { if ( typeof actions === 'string' ) { add ( actions ) ; } else if ( Array . isArray ( actions ) ) { actions . forEach ( addActions ) ; } else if ( typeof actions === 'object' ) { for ( var type in actions ) { add ( type , actions [ type ] ) ; } } }


Input: INDEXSPACE FUNCTION : indexspace ( str len ) Generates a linearly spaced index array from a subsequence string . [CODESPLIT] function indexspace ( str , len ) { var x1 , x2 , tmp , inc , arr ; if ( ! isString ( str ) || ! re . test ( str ) ) { throw new Error ( 'indexspace()::invalid input argument. Invalid subsequence syntax. Please consult documentation. Value: `' + str + '`.' ) ; } if ( ! isNonNegativeInteger ( len ) ) { throw new TypeError ( 'indexspace()::invalid input argument. Reference array length must be a nonnegative integer. Value: `' + len + '`.' ) ; } if ( ! len ) { return [ ] ; } str = str . split ( ':' ) ; x1 = str [ 0 ] ; x2 = str [ 1 ] ; if ( str . length === 2 ) { inc = 1 ; } else { inc = parseInt ( str [ 2 ] , 10 ) ; } // Handle zero increment... if ( inc === 0 ) { throw new Error ( 'indexspace()::invalid syntax. Increment must be an integer not equal to 0. Value: `' + inc + '`.' ) ; } // START // // Handle use of 'end' keyword... if ( reEnd . test ( x1 ) ) { tmp = x1 . match ( reMatch ) ; if ( tmp ) { if ( tmp [ 1 ] === '-' ) { x1 = len - 1 - parseInt ( tmp [ 2 ] , 10 ) ; if ( x1 < 0 ) { // WARNING: forgive the user for exceeding the range bounds... x1 = 0 ; } } else { x1 = ( len - 1 ) / parseInt ( tmp [ 2 ] , 10 ) ; x1 = Math . ceil ( x1 ) ; } } else { x1 = len - 1 ; } } else { x1 = parseInt ( x1 , 10 ) ; // Handle empty index... if ( x1 !== x1 ) { // :-?\d*:-?\d+ if ( inc < 0 ) { // Max index: x1 = len - 1 ; } else { // Min index: x1 = 0 ; } } // Handle negative index... else if ( x1 < 0 ) { x1 = len + x1 ; // len-x1 if ( x1 < 0 ) { // WARNING: forgive the user for exceeding index bounds... x1 = 0 ; } } // Handle exceeding bounds... else if ( x1 >= len ) { return [ ] ; } } // END // // NOTE: here, we determine an inclusive `end` value; i.e., the last acceptable index value. // Handle use of 'end' keyword... if ( reEnd . test ( x2 ) ) { tmp = x2 . match ( reMatch ) ; if ( tmp ) { if ( tmp [ 1 ] === '-' ) { x2 = len - 1 - parseInt ( tmp [ 2 ] , 10 ) ; if ( x2 < 0 ) { // WARNING: forgive the user for exceeding the range bounds... x2 = 0 ; } } else { x2 = ( len - 1 ) / parseInt ( tmp [ 2 ] , 10 ) ; x2 = Math . ceil ( x2 ) - 1 ; } } else { x2 = len - 1 ; } } else { x2 = parseInt ( x2 , 10 ) ; // Handle empty index... if ( x2 !== x2 ) { // -?\d*::-?\d+ if ( inc < 0 ) { // Min index: x2 = 0 ; } else { // Max index: x2 = len - 1 ; } } // Handle negative index... else if ( x2 < 0 ) { x2 = len + x2 ; // len-x2 if ( x2 < 0 ) { // WARNING: forgive the user for exceeding index bounds... x2 = 0 ; } if ( inc > 0 ) { x2 = x2 - 1 ; } } // Handle positive index... else { if ( inc < 0 ) { x2 = x2 + 1 ; } else if ( x2 >= len ) { x2 = len - 1 ; } else { x2 = x2 - 1 ; } } } // INDICES // arr = [ ] ; if ( inc < 0 ) { if ( x2 > x1 ) { return arr ; } while ( x1 >= x2 ) { arr . push ( x1 ) ; x1 += inc ; } } else { if ( x1 > x2 ) { return arr ; } while ( x1 <= x2 ) { arr . push ( x1 ) ; x1 += inc ; } } return arr ; }


Input: Appends an event handler to an element . The shorthand version { @link #on } is equivalent . Typically you will use { @link Ext . Element#addListener } directly on an Element in favor of calling this version . @param { String / HTMLElement } el The HTML element or id to assign the event handler to . @param { String } eventName The name of the event to listen for . @param { Function } handler The handler function the event invokes . This function is passed the following parameters : @param { Ext . EventObject } handler . evt The { @link Ext . EventObject EventObject } describing the event . @param { Ext . Element } handler . t The { @link Ext . Element Element } which was the target of the event . Note that this may be filtered by using the delegate option . @param { Object } handler . o The options object from the addListener call . @param { Object } scope ( optional ) The scope ( this reference ) in which the handler function is executed . __Defaults to the Element__ . @param { Object } options ( optional ) An object containing handler configuration properties . This may contain any of the following properties : @param { Object } [ options . scope ] The scope ( this reference ) in which the handler function is executed . __Defaults to the Element__ . @param { String } [ options . delegate ] A simple selector to filter the target or look for a descendant of the target . @param { Boolean } [ options . stopEvent ] true to stop the event . That is stop propagation and prevent the default action . @param { Boolean } [ options . preventDefault ] true to prevent the default action . @param { Boolean } [ options . stopPropagation ] true to prevent event propagation . @param { Boolean } [ options . normalized ] false to pass a browser event to the handler function instead of an Ext . EventObject . @param { Number } [ options . delay ] The number of milliseconds to delay the invocation of the handler after the event fires . @param { Boolean } [ options . single ] true to add a handler to handle just the next firing of the event and then remove itself . @param { Number } [ options . buffer ] Causes the handler to be scheduled to run in an { @link Ext . util . DelayedTask } delayed by the specified number of milliseconds . If the event fires again within that time the original handler is _not_ invoked but the new handler is scheduled in its place . @param { Ext . Element } [ options . target ] Only call the handler if the event was fired on the target Element _not_ if the event was bubbled up from a child node . [CODESPLIT] function ( element , eventName , fn , scope , options ) { //<debug warn> Ext . Logger . deprecate ( "Ext.EventManager.addListener is deprecated, use addListener() directly from an instance of Ext.Element instead" , 2 ) ; //</debug> element . on ( eventName , fn , scope , options ) ; }


Input: Removes an event handler from an element . The shorthand version { [CODESPLIT] function ( element , eventName , fn , scope ) { //<debug warn> Ext . Logger . deprecate ( "Ext.EventManager.removeListener is deprecated, use removeListener() directly from an instance of Ext.Element instead" , 2 ) ; //</debug> element . un ( eventName , fn , scope ) ; }


Input: Adds a listener to be notified when the browser window is resized and provides resize event buffering ( 50 milliseconds ) passes new viewport width and height to handlers . [CODESPLIT] function ( fn , scope , options ) { //<debug warn> Ext . Logger . deprecate ( "Ext.EventManager.onWindowResize is deprecated, attach listener to Ext.Viewport instead, i.e: Ext.Viewport.on('resize', ...)" , 2 ) ; //</debug> Ext . Viewport . on ( 'resize' , fn , scope , options ) ; }


Input: Returns a string with a specified number of repetitions a given string pattern . The pattern be separated by a different string . [CODESPLIT] function ( pattern , count , sep ) { for ( var buf = [ ] , i = count ; i -- ; ) { buf . push ( pattern ) ; } return buf . join ( sep || '' ) ; }


Input: Send a file to a server [CODESPLIT] function ( config ) { var options = new FileUploadOptions ( ) ; options . fileKey = config . fileKey || "file" ; options . fileName = this . path . substr ( this . path . lastIndexOf ( '/' ) + 1 ) ; options . mimeType = config . mimeType || "image/jpeg" ; options . params = config . params || { } ; options . headers = config . headers || { } ; options . chunkMode = config . chunkMode || true ; var fileTransfer = new FileTransfer ( ) ; fileTransfer . upload ( this . path , encodeURI ( config . url ) , config . success , config . failure , options , config . trustAllHosts || false ) ; return fileTransfer ; }


Input: Downloads a file from the server saving it into the Local File System [CODESPLIT] function ( config ) { var fileTransfer = new FileTransfer ( ) ; fileTransfer . download ( encodeURI ( config . source ) , this . path , config . success , config . failure , config . trustAllHosts || false , config . options || { } ) ; return fileTransfer ; }


Input: This method will sort a collection based on the currently configured sorters . [CODESPLIT] function ( property , value , anyMatch , caseSensitive ) { // Support for the simple case of filtering by property/value if ( property ) { if ( Ext . isString ( property ) ) { this . addFilters ( { property : property , value : value , anyMatch : anyMatch , caseSensitive : caseSensitive } ) ; return this . items ; } else { this . addFilters ( property ) ; return this . items ; } } this . items = this . mixins . filterable . filter . call ( this , this . all . slice ( ) ) ; this . updateAfterFilter ( ) ; if ( this . sorted && this . getAutoSort ( ) ) { this . sort ( ) ; } }


Input: Adds an item to the collection . @param { String } key [CODESPLIT] function ( key , item ) { var me = this , filtered = this . filtered , sorted = this . sorted , all = this . all , items = this . items , keys = this . keys , indices = this . indices , filterable = this . mixins . filterable , currentLength = items . length , index = currentLength ; if ( arguments . length == 1 ) { item = key ; key = me . getKey ( item ) ; } if ( typeof key != 'undefined' && key !== null ) { if ( typeof me . map [ key ] != 'undefined' ) { return me . replace ( key , item ) ; } me . map [ key ] = item ; } all . push ( item ) ; if ( filtered && this . getAutoFilter ( ) && filterable . isFiltered . call ( me , item ) ) { return null ; } me . length ++ ; if ( sorted && this . getAutoSort ( ) ) { index = this . findInsertionIndex ( items , item ) ; } if ( index !== currentLength ) { this . dirtyIndices = true ; Ext . Array . splice ( keys , index , 0 , key ) ; Ext . Array . splice ( items , index , 0 , item ) ; } else { indices [ key ] = currentLength ; keys . push ( key ) ; items . push ( item ) ; } return item ; }


Input: Replaces an item in the collection . Fires the { @link #replace } event when complete . @param { String } oldKey [CODESPLIT] function ( oldKey , item ) { var me = this , sorted = me . sorted , presorted = me . presorted , filtered = me . filtered , filterable = me . mixins . filterable , items = me . items , keys = me . keys , all = me . all , map = me . map , returnItem = null , oldItemsLn = items . length , subjectToOptimize = false , oldItem , index , newKey ; if ( arguments . length == 1 ) { item = oldKey ; oldKey = newKey = me . getKey ( item ) ; subjectToOptimize = true ; } else { newKey = me . getKey ( item ) ; } oldItem = map [ oldKey ] ; if ( typeof oldKey == 'undefined' || oldKey === null || typeof oldItem == 'undefined' ) { return me . add ( newKey , item ) ; } me . map [ newKey ] = item ; if ( newKey !== oldKey ) { delete me . map [ oldKey ] ; } if ( sorted && me . getAutoSort ( ) ) { if ( ! subjectToOptimize ) { Ext . Array . remove ( items , oldItem ) ; Ext . Array . remove ( keys , oldKey ) ; } else { var itemsFrom = items . indexOf ( oldItem ) ; } if ( ! presorted ) { Ext . Array . remove ( all , oldItem ) ; all . push ( item ) ; me . dirtyIndices = true ; } else { var allTo = this . findInsertionIndex ( all , item , undefined , true ) , allFrom = all . indexOf ( item ) ; if ( allTo !== allFrom ) { move ( all , allFrom , allTo ) ; me . dirtyIndices = true ; } } if ( filtered && me . getAutoFilter ( ) ) { // If the item is now filtered we check if it was not filtered // before. If that is the case then we subtract from the length if ( filterable . isFiltered . call ( me , item ) ) { if ( oldItemsLn !== items . length ) { me . length -- ; } if ( subjectToOptimize ) { Ext . Array . remove ( items , oldItem ) ; Ext . Array . remove ( keys , oldKey ) ; } return null ; } // If the item was filtered, but now it is not anymore then we // add to the length else if ( oldItemsLn === items . length ) { me . length ++ ; returnItem = item ; } } if ( ! subjectToOptimize ) { index = this . findInsertionIndex ( items , item ) ; Ext . Array . splice ( keys , index , 0 , newKey ) ; Ext . Array . splice ( items , index , 0 , item ) ; } else { index = this . findInsertionIndex ( items , item , undefined , true ) ; move ( keys , itemsFrom , index ) ; move ( items , itemsFrom , index ) ; } } else { if ( filtered ) { if ( me . getAutoFilter ( ) && filterable . isFiltered . call ( me , item ) ) { if ( me . indexOf ( oldItem ) !== - 1 ) { Ext . Array . remove ( items , oldItem ) ; Ext . Array . remove ( keys , oldKey ) ; me . length -- ; me . dirtyIndices = true ; } return null ; } else if ( me . indexOf ( oldItem ) === - 1 ) { items . push ( item ) ; keys . push ( newKey ) ; me . indices [ newKey ] = me . length ; me . length ++ ; return item ; } } index = me . indexOf ( oldItem ) ; keys [ index ] = newKey ; items [ index ] = item ; if ( newKey !== oldKey ) { this . dirtyIndices = true ; } } return returnItem ; function move ( array , from , to ) { if ( to === from ) return ; var target = array [ from ] ; var increment = to < from ? - 1 : 1 ; for ( var k = from ; k != to ; k += increment ) { array [ k ] = array [ k + increment ] ; } array [ to ] = target ; } }


Input: Adds all elements of an Array or an Object to the collection . [CODESPLIT] function ( addItems ) { var me = this , filtered = me . filtered , sorted = me . sorted , all = me . all , items = me . items , keys = me . keys , map = me . map , autoFilter = me . getAutoFilter ( ) , autoSort = me . getAutoSort ( ) , newKeys = [ ] , newItems = [ ] , filterable = me . mixins . filterable , addedItems = [ ] , ln , key , i , item ; if ( Ext . isObject ( addItems ) ) { for ( key in addItems ) { if ( addItems . hasOwnProperty ( key ) ) { newItems . push ( items [ key ] ) ; newKeys . push ( key ) ; } } } else { newItems = addItems ; ln = addItems . length ; for ( i = 0 ; i < ln ; i ++ ) { newKeys . push ( me . getKey ( addItems [ i ] ) ) ; } } for ( i = 0 ; i < ln ; i ++ ) { key = newKeys [ i ] ; item = newItems [ i ] ; if ( typeof key != 'undefined' && key !== null ) { if ( typeof map [ key ] != 'undefined' ) { me . replace ( key , item ) ; continue ; } map [ key ] = item ; } all . push ( item ) ; if ( filtered && autoFilter && filterable . isFiltered . call ( me , item ) ) { continue ; } me . length ++ ; keys . push ( key ) ; items . push ( item ) ; addedItems . push ( item ) ; } if ( addedItems . length ) { me . dirtyIndices = true ; if ( sorted && autoSort ) { me . sort ( ) ; } return addedItems ; } return null ; }


Input: Executes the specified function once for every key in the collection passing each key and its associated item as the first two parameters . [CODESPLIT] function ( fn , scope ) { var keys = this . keys , items = this . items , ln = keys . length , i ; for ( i = 0 ; i < ln ; i ++ ) { fn . call ( scope || window , keys [ i ] , items [ i ] , i , ln ) ; } }


Input: Filter by a function . Returns a _new_ collection that has been filtered . The passed function will be called with each object in the collection . If the function returns true the value is included otherwise it is filtered . [CODESPLIT] function ( fn , scope ) { var me = this , newCollection = new this . self ( ) , keys = me . keys , items = me . all , length = items . length , i ; newCollection . getKey = me . getKey ; for ( i = 0 ; i < length ; i ++ ) { if ( fn . call ( scope || me , items [ i ] , me . getKey ( items [ i ] ) ) ) { newCollection . add ( keys [ i ] , items [ i ] ) ; } } return newCollection ; }


Input: Inserts an item at the specified index in the collection . Fires the { [CODESPLIT] function ( index , key , item ) { var me = this , sorted = this . sorted , map = this . map , filtered = this . filtered ; if ( arguments . length == 2 ) { item = key ; key = me . getKey ( item ) ; } if ( index >= me . length || ( sorted && me . getAutoSort ( ) ) ) { return me . add ( key , item ) ; } if ( typeof key != 'undefined' && key !== null ) { if ( typeof map [ key ] != 'undefined' ) { me . replace ( key , item ) ; return false ; } map [ key ] = item ; } this . all . push ( item ) ; if ( filtered && this . getAutoFilter ( ) && this . mixins . filterable . isFiltered . call ( me , item ) ) { return null ; } me . length ++ ; Ext . Array . splice ( me . items , index , 0 , item ) ; Ext . Array . splice ( me . keys , index , 0 , key ) ; me . dirtyIndices = true ; return item ; }


Input: Remove an item from the collection . [CODESPLIT] function ( item ) { var index = this . items . indexOf ( item ) ; if ( index === - 1 ) { Ext . Array . remove ( this . all , item ) ; if ( typeof this . getKey == 'function' ) { var key = this . getKey ( item ) ; if ( key !== undefined ) { delete this . map [ key ] ; } } return item ; } return this . removeAt ( this . items . indexOf ( item ) ) ; }


Input: Remove all items in the passed array from the collection . [CODESPLIT] function ( items ) { if ( items ) { var ln = items . length , i ; for ( i = 0 ; i < ln ; i ++ ) { this . remove ( items [ i ] ) ; } } return this ; }


Input: Remove an item from a specified index in the collection . Fires the { [CODESPLIT] function ( index ) { var me = this , items = me . items , keys = me . keys , all = me . all , item , key ; if ( index < me . length && index >= 0 ) { item = items [ index ] ; key = keys [ index ] ; if ( typeof key != 'undefined' ) { delete me . map [ key ] ; } Ext . Array . erase ( items , index , 1 ) ; Ext . Array . erase ( keys , index , 1 ) ; Ext . Array . remove ( all , item ) ; delete me . indices [ key ] ; me . length -- ; this . dirtyIndices = true ; return item ; } return false ; }


Input: Returns index within the collection of the passed Object . [CODESPLIT] function ( item ) { if ( this . dirtyIndices ) { this . updateIndices ( ) ; } var index = item ? this . indices [ this . getKey ( item ) ] : - 1 ; return ( index === undefined ) ? - 1 : index ; }


Input: Returns the item associated with the passed key OR index . Key has priority over index . This is the equivalent of calling { [CODESPLIT] function ( key ) { var me = this , fromMap = me . map [ key ] , item ; if ( fromMap !== undefined ) { item = fromMap ; } else if ( typeof key == 'number' ) { item = me . items [ key ] ; } return typeof item != 'function' || me . getAllowFunctions ( ) ? item : null ; // for prototype! }


Input: Returns true if the collection contains the passed Object as an item . [CODESPLIT] function ( item ) { var key = this . getKey ( item ) ; if ( key ) { return this . containsKey ( key ) ; } else { return Ext . Array . contains ( this . items , item ) ; } }


Input: Removes all items from the collection . Fires the { [CODESPLIT] function ( ) { var me = this ; me . length = 0 ; me . items . length = 0 ; me . keys . length = 0 ; me . all . length = 0 ; me . dirtyIndices = true ; me . indices = { } ; me . map = { } ; }


Input: Returns a range of items in this collection [CODESPLIT] function ( start , end ) { var me = this , items = me . items , range = [ ] , i ; if ( items . length < 1 ) { return range ; } start = start || 0 ; end = Math . min ( typeof end == 'undefined' ? me . length - 1 : end , me . length - 1 ) ; if ( start <= end ) { for ( i = start ; i <= end ; i ++ ) { range [ range . length ] = items [ i ] ; } } else { for ( i = start ; i >= end ; i -- ) { range [ range . length ] = items [ i ] ; } } return range ; }


Input: Find the index of the first matching object in this collection by a function . If the function returns true it is considered a match . [CODESPLIT] function ( fn , scope , start ) { var me = this , keys = me . keys , items = me . items , i = start || 0 , ln = items . length ; for ( ; i < ln ; i ++ ) { if ( fn . call ( scope || me , items [ i ] , keys [ i ] ) ) { return i ; } } return - 1 ; }


Input: Creates a shallow copy of this collection [CODESPLIT] function ( ) { var me = this , copy = new this . self ( ) , keys = me . keys , items = me . items , i = 0 , ln = items . length ; for ( ; i < ln ; i ++ ) { copy . add ( keys [ i ] , items [ i ] ) ; } copy . getKey = me . getKey ; return copy ; }


Input: Updates the monthText configuration [CODESPLIT] function ( newMonthText , oldMonthText ) { var innerItems = this . getInnerItems , ln = innerItems . length , item , i ; //loop through each of the current items and set the title on the correct slice if ( this . initialized ) { for ( i = 0 ; i < ln ; i ++ ) { item = innerItems [ i ] ; if ( ( typeof item . title == "string" && item . title == oldMonthText ) || ( item . title . html == oldMonthText ) ) { item . setTitle ( newMonthText ) ; } } } }


Input: Updates the { [CODESPLIT] function ( newDayText , oldDayText ) { var innerItems = this . getInnerItems , ln = innerItems . length , item , i ; //loop through each of the current items and set the title on the correct slice if ( this . initialized ) { for ( i = 0 ; i < ln ; i ++ ) { item = innerItems [ i ] ; if ( ( typeof item . title == "string" && item . title == oldDayText ) || ( item . title . html == oldDayText ) ) { item . setTitle ( newDayText ) ; } } } }


Input: Updates the yearText configuration [CODESPLIT] function ( yearText ) { var innerItems = this . getInnerItems , ln = innerItems . length , item , i ; //loop through each of the current items and set the title on the correct slice if ( this . initialized ) { for ( i = 0 ; i < ln ; i ++ ) { item = innerItems [ i ] ; if ( item . title == this . yearText ) { item . setTitle ( yearText ) ; } } } }


Input: Generates all slots for all years specified by this component and then sets them on the component [CODESPLIT] function ( ) { var me = this , slotOrder = me . getSlotOrder ( ) , yearsFrom = me . getYearFrom ( ) , yearsTo = me . getYearTo ( ) , years = [ ] , days = [ ] , months = [ ] , reverse = yearsFrom > yearsTo , ln , i , daysInMonth ; while ( yearsFrom ) { years . push ( { text : yearsFrom , value : yearsFrom } ) ; if ( yearsFrom === yearsTo ) { break ; } if ( reverse ) { yearsFrom -- ; } else { yearsFrom ++ ; } } daysInMonth = me . getDaysInMonth ( 1 , new Date ( ) . getFullYear ( ) ) ; for ( i = 0 ; i < daysInMonth ; i ++ ) { days . push ( { text : i + 1 , value : i + 1 } ) ; } for ( i = 0 , ln = Ext . Date . monthNames . length ; i < ln ; i ++ ) { months . push ( { text : Ext . Date . monthNames [ i ] , value : i + 1 } ) ; } var slots = [ ] ; slotOrder . forEach ( function ( item ) { slots . push ( me . createSlot ( item , days , months , years ) ) ; } ) ; me . setSlots ( slots ) ; }


Input: Returns a slot config for a specified date . [CODESPLIT] function ( name , days , months , years ) { switch ( name ) { case 'year' : return { name : 'year' , align : 'center' , data : years , title : this . getYearText ( ) , flex : 3 } ; case 'month' : return { name : name , align : 'right' , data : months , title : this . getMonthText ( ) , flex : 4 } ; case 'day' : return { name : 'day' , align : 'center' , data : days , title : this . getDayText ( ) , flex : 2 } ; } }


Input: / * KADEMLIA TRANSPORT [CODESPLIT] function ( contact , options ) { this . messaging = options . messaging kademlia . RPC . call ( this , contact , options ) }


Input: A private function for rendering decision [CODESPLIT] function ( user ) { if ( user ) { if ( ! ! ~ this . roles . indexOf ( '*' ) ) { return true ; } else { for ( var userRoleIndex in user . roles ) { for ( var roleIndex in this . roles ) { if ( this . roles [ roleIndex ] === user . roles [ userRoleIndex ] ) { return true ; } } } } } else { return this . isPublic ; } return false ; }


Input: Calculates and returns the position values needed for the back button when you are pushing a title . [CODESPLIT] function ( oldLeft , oldTitle , reverse ) { var me = this , barElement = me . element , newLeftElement = me . leftBox . element , titleElement = me . titleComponent . element , minOffset = Math . min ( barElement . getWidth ( ) / 3 , 200 ) , newLeftWidth = newLeftElement . getWidth ( ) , barX = barElement . getX ( ) , barWidth = barElement . getWidth ( ) , titleX = titleElement . getX ( ) , titleLeft = titleElement . getLeft ( ) , titleWidth = titleElement . getWidth ( ) , oldLeftX = oldLeft . x , oldLeftWidth = oldLeft . width , oldLeftLeft = oldLeft . left , useLeft = Ext . browser . is . AndroidStock2 && ! this . getAndroid2Transforms ( ) , newOffset , oldOffset , leftAnims , titleAnims , omega , theta ; theta = barX - oldLeftX - oldLeftWidth ; if ( reverse ) { newOffset = theta ; oldOffset = Math . min ( titleX - oldLeftWidth , minOffset ) ; } else { oldOffset = theta ; newOffset = Math . min ( titleX - barX , minOffset ) ; } if ( useLeft ) { leftAnims = { element : { from : { left : newOffset , opacity : 1 } , to : { left : 0 , opacity : 1 } } } ; } else { leftAnims = { element : { from : { transform : { translateX : newOffset } , opacity : 0 } , to : { transform : { translateX : 0 } , opacity : 1 } } , ghost : { to : { transform : { translateX : oldOffset } , opacity : 0 } } } ; } theta = barX - titleX + newLeftWidth ; if ( ( oldLeftLeft + titleWidth ) > titleX ) { omega = barX - titleX - titleWidth ; } if ( reverse ) { titleElement . setLeft ( 0 ) ; oldOffset = barX + barWidth - titleX - titleWidth ; if ( omega !== undefined ) { newOffset = omega ; } else { newOffset = theta ; } } else { newOffset = barX + barWidth - titleX - titleWidth ; if ( omega !== undefined ) { oldOffset = omega ; } else { oldOffset = theta ; } newOffset = Math . max ( titleLeft , newOffset ) ; } if ( useLeft ) { titleAnims = { element : { from : { left : newOffset , opacity : 1 } , to : { left : titleLeft , opacity : 1 } } } ; } else { titleAnims = { element : { from : { transform : { translateX : newOffset } , opacity : 0 } , to : { transform : { translateX : titleLeft } , opacity : 1 } } , ghost : { to : { transform : { translateX : oldOffset } , opacity : 0 } } } ; } return { left : leftAnims , title : titleAnims , titleLeft : titleLeft } ; }


Input: Helper method used to animate elements . You pass it an element objects for the from and to positions an option onEnd callback called when the animation is over . Normally this method is passed configurations returned from the methods such as #measureTitle ( true ) etc . It is called from the #pushLeftBoxAnimated #pushTitleAnimated #popBackButtonAnimated and #popTitleAnimated methods . [CODESPLIT] function ( element , config , callback ) { var me = this , animation ; //reset the left of the element element . setLeft ( 0 ) ; config = Ext . apply ( config , { element : element , easing : 'ease-in-out' , duration : me . getAnimation ( ) . duration || 250 , preserveEndState : true } ) ; animation = new Ext . fx . Animation ( config ) ; animation . on ( 'animationend' , function ( ) { if ( callback ) { callback . call ( me ) ; } } , me ) ; Ext . Animator . run ( animation ) ; me . activeAnimations . push ( animation ) ; }


Input: Returns the text needed for the current back button at anytime . [CODESPLIT] function ( ) { var text = this . backButtonStack [ this . backButtonStack . length - 2 ] , useTitleForBackButtonText = this . getUseTitleForBackButtonText ( ) ; if ( ! useTitleForBackButtonText ) { if ( text ) { text = this . getDefaultBackButtonText ( ) ; } } return text ; }


Input: We override the hidden method because we don t want to remove it from the view using display : none . Instead we just position it off the screen much like the navigation bar proxy . This means that all animations pushing popping etc . all still work when if you hide / show this bar at any time . [CODESPLIT] function ( hidden ) { if ( ! hidden ) { this . element . setStyle ( { position : 'relative' , top : 'auto' , left : 'auto' , width : 'auto' } ) ; } else { this . element . setStyle ( { position : 'absolute' , top : '-1000px' , left : '-1000px' , width : this . element . getWidth ( ) + 'px' } ) ; } }


Input: Creates a proxy element of the passed element and positions it in the same position using absolute positioning . The createNavigationBarProxy method uses this to create proxies of the backButton and the title elements . [CODESPLIT] function ( element ) { var ghost , x , y , left , width ; ghost = element . dom . cloneNode ( true ) ; ghost . id = element . id + '-proxy' ; //insert it into the toolbar element . getParent ( ) . dom . appendChild ( ghost ) ; //set the x/y ghost = Ext . get ( ghost ) ; x = element . getX ( ) ; y = element . getY ( ) ; left = element . getLeft ( ) ; width = element . getWidth ( ) ; ghost . setStyle ( 'position' , 'absolute' ) ; ghost . setX ( x ) ; ghost . setY ( y ) ; ghost . setHeight ( element . getHeight ( ) ) ; ghost . setWidth ( width ) ; return { x : x , y : y , left : left , width : width , ghost : ghost } ; }


Input: A Metalsmith plugin to extract untemplatized file contents . [CODESPLIT] function plugin ( options ) { options = options || { } ; options . key = options . key || 'untemplatized' ; return function ( files , metalsmith , done ) { setImmediate ( done ) ; Object . keys ( files ) . forEach ( function ( file ) { debug ( 'checking file: %s' , file ) ; var data = files [ file ] ; var contents = data . contents . toString ( ) . replace ( / ^\n+ / g , '' ) ; debug ( 'storing untemplatized content: %s' , file ) ; data [ options . key ] = new Buffer ( contents ) ; } ) ; } ; }


Input: Defines a metric that measures latency by last req / res [CODESPLIT] function LatencyMetric ( ) { if ( ! ( this instanceof LatencyMetric ) ) { return new LatencyMetric ( ) } Metric . call ( this ) this . key = 'latency' this . default = [ 0 ] this . hooks = [ { trigger : 'before' , event : 'send' , handler : this . _start } , { trigger : 'before' , event : 'receive' , handler : this . _stop } ] this . _tests = { } setInterval ( this . _expireTimeouts . bind ( this ) , LatencyMetric . TEST_TIMEOUT ) }


Input: dataType : json others [CODESPLIT] function decodeResult ( contentType , dataType , result ) { if ( dataType == 'json' ) { try { result = JSON . parse ( result ) ; return result ; } catch ( e ) { } } if ( contentType && contentType . indexOf ( 'application/json' ) == 0 ) { try { result = JSON . parse ( result ) ; } catch ( e ) { } } //todo: xml result return result ; }


Input: Default map will take the first this . header . length items from the object as the row values [CODESPLIT] function defaultMapFn ( data ) { return Object . keys ( data ) . slice ( 0 , this . headers . length ) . map ( function ( key ) { return data [ key ] } ) }


Input: Schedule a new Job [CODESPLIT] function scheduleJob ( trigger , jobFunc , jobData ) { const job = Job . createJob ( trigger , jobFunc , jobData ) ; const excuteTime = job . excuteTime ( ) ; const id = job . id ; map [ id ] = job ; const element = { id : id , time : excuteTime } ; const curJob = queue . peek ( ) ; if ( ! curJob || excuteTime < curJob . time ) { queue . offer ( element ) ; setTimer ( job ) ; return job . id ; } queue . offer ( element ) ; return job . id ; }


Input: Add / override static properties of this class . [CODESPLIT] function ( members ) { var member , name ; //<debug> var className = Ext . getClassName ( this ) ; //</debug> for ( name in members ) { if ( members . hasOwnProperty ( name ) ) { member = members [ name ] ; //<debug> if ( typeof member == 'function' ) { member . displayName = className + '.' + name ; } //</debug> this [ name ] = member ; } } return this ; }


Input: Add methods / properties to the prototype of this class . [CODESPLIT] function ( members ) { var prototype = this . prototype , names = [ ] , name , member ; //<debug> var className = this . $className || '' ; //</debug> for ( name in members ) { if ( members . hasOwnProperty ( name ) ) { member = members [ name ] ; if ( typeof member == 'function' && ! member . $isClass && member !== Ext . emptyFn ) { member . $owner = this ; member . $name = name ; //<debug> member . displayName = className + '#' + name ; //</debug> } prototype [ name ] = member ; } } return this ; }


Input: Override members of this class . Overridden methods can be invoked via { @link Ext . Base#callParent } . [CODESPLIT] function ( members ) { var me = this , enumerables = Ext . enumerables , target = me . prototype , cloneFunction = Ext . Function . clone , currentConfig = target . config , name , index , member , statics , names , previous , newConfig , prop ; if ( arguments . length === 2 ) { name = members ; members = { } ; members [ name ] = arguments [ 1 ] ; enumerables = null ; } do { names = [ ] ; // clean slate for prototype (1st pass) and static (2nd pass) statics = null ; // not needed 1st pass, but needs to be cleared for 2nd pass for ( name in members ) { // hasOwnProperty is checked in the next loop... if ( name == 'statics' ) { statics = members [ name ] ; } else if ( name == 'config' ) { newConfig = members [ name ] ; //<debug error> for ( prop in newConfig ) { if ( ! ( prop in currentConfig ) ) { throw new Error ( "Attempting to override a non-existant config property. This is not " + "supported, you must extend the Class." ) ; } } //</debug> me . addConfig ( newConfig , true ) ; } else { names . push ( name ) ; } } if ( enumerables ) { names . push . apply ( names , enumerables ) ; } for ( index = names . length ; index -- ; ) { name = names [ index ] ; if ( members . hasOwnProperty ( name ) ) { var inherited = false ; member = members [ name ] ; if ( typeof member == 'function' && ! member . $className && member !== Ext . emptyFn ) { if ( typeof member . $owner != 'undefined' ) { member = cloneFunction ( member ) ; } //<debug> var className = me . $className ; if ( className ) { member . displayName = className + '#' + name ; } //</debug> member . $owner = me ; member . $name = name ; previous = target [ name ] ; if ( previous == null ) { previous = this [ name ] ; if ( previous ) { inherited = true ; } } if ( previous ) { member . $previous = previous ; } } if ( ! inherited ) { target [ name ] = member ; } else { this [ name ] = member ; } } } target = me ; // 2nd pass is for statics members = statics ; // statics will be null on 2nd pass } while ( members ) ; return this ; }


Input: <feature classSystem . mixins > Used internally by the mixins pre - processor [CODESPLIT] function ( name , mixinClass ) { var mixin = mixinClass . prototype , prototype = this . prototype , key ; if ( typeof mixin . onClassMixedIn != 'undefined' ) { mixin . onClassMixedIn . call ( mixinClass , this ) ; } if ( ! prototype . hasOwnProperty ( 'mixins' ) ) { if ( 'mixins' in prototype ) { prototype . mixins = Ext . Object . chain ( prototype . mixins ) ; } else { prototype . mixins = { } ; } } for ( key in mixin ) { if ( key === 'mixins' ) { Ext . merge ( prototype . mixins , mixin [ key ] ) ; } else if ( typeof prototype [ key ] == 'undefined' && key != 'mixinId' && key != 'config' ) { prototype [ key ] = mixin [ key ] ; } } //<feature classSystem.config> if ( 'config' in mixin ) { this . addConfig ( mixin . config , false ) ; } //</feature> prototype . mixins [ name ] = mixin ; }


Input: Call the original method that was previously overridden with { @link Ext . Base#override } [CODESPLIT] function ( args ) { var callOverriddenFn = this . callOverridden || this . prototype . callOverridden , method = callOverriddenFn . caller , previousMethod = method && method . $previous ; if ( ! previousMethod ) { return method . $return ; } return previousMethod . apply ( this , args || noArgs ) ; }


Input: Initialize configuration for this class . a typical example : [CODESPLIT] function ( instanceConfig ) { //<debug> //            if (instanceConfig && instanceConfig.breakOnInitConfig) { //                debugger; //            } //</debug> var configNameCache = Ext . Class . configNameCache , prototype = this . self . prototype , initConfigList = this . initConfigList , initConfigMap = this . initConfigMap , config = new this . configClass , defaultConfig = this . defaultConfig , i , ln , name , value , nameMap , getName ; this . initConfig = Ext . emptyFn ; this . initialConfig = instanceConfig || { } ; if ( instanceConfig ) { Ext . merge ( config , instanceConfig ) ; } this . config = config ; // Optimize initConfigList *once* per class based on the existence of apply* and update* methods // Happens only once during the first instantiation if ( ! prototype . hasOwnProperty ( 'wasInstantiated' ) ) { prototype . wasInstantiated = true ; for ( i = 0 , ln = initConfigList . length ; i < ln ; i ++ ) { name = initConfigList [ i ] ; nameMap = configNameCache [ name ] ; value = defaultConfig [ name ] ; if ( ! ( nameMap . apply in prototype ) && ! ( nameMap . update in prototype ) && prototype [ nameMap . set ] . $isDefault && typeof value != 'object' ) { prototype [ nameMap . internal ] = defaultConfig [ name ] ; initConfigMap [ name ] = false ; Ext . Array . remove ( initConfigList , name ) ; i -- ; ln -- ; } } } if ( instanceConfig ) { initConfigList = initConfigList . slice ( ) ; for ( name in instanceConfig ) { if ( name in defaultConfig && ! initConfigMap [ name ] ) { initConfigList . push ( name ) ; } } } // Point all getters to the initGetters for ( i = 0 , ln = initConfigList . length ; i < ln ; i ++ ) { name = initConfigList [ i ] ; nameMap = configNameCache [ name ] ; this [ nameMap . get ] = this [ nameMap . initGet ] ; } this . beforeInitConfig ( config ) ; for ( i = 0 , ln = initConfigList . length ; i < ln ; i ++ ) { name = initConfigList [ i ] ; nameMap = configNameCache [ name ] ; getName = nameMap . get ; if ( this . hasOwnProperty ( getName ) ) { this [ nameMap . set ] . call ( this , config [ name ] ) ; delete this [ getName ] ; } } return this ; }


Input: Define a new type . [CODESPLIT] function defineType ( type , validator ) { var typeDef ; var regKey ; if ( type instanceof Function ) { validator = _customValidator ( type ) ; type = type . name ; //console.log("Custom type", typeof type, type, validator); } else if ( ! ( validator instanceof Function ) ) { throw TypeException ( 'Validator must be a function for `{{type}}`' , null , null , { type : type } ) ; } typeDef = parseTypeDef ( type ) ; regKey = typeDef . name . toLocaleLowerCase ( ) ; if ( primitives [ regKey ] ) { throw TypeException ( 'Cannot override primitive type `{{type}}`' , null , null , { type : typeDef . name } ) ; } else if ( registry [ regKey ] && ( registry [ regKey ] . validator !== validator ) ) { throw TypeException ( 'Validator conflict for type `{{type}}` ' , null , null , { type : typeDef . name } ) ; } registry [ regKey ] = { type : typeDef . name , validator : validator } ; return validator ; }


Input: Undefine a type . [CODESPLIT] function undefineType ( type ) { var validator ; var typeDef = parseTypeDef ( type ) ; var regKey = typeDef . name . toLocaleLowerCase ( ) ; if ( primitives [ regKey ] ) { throw TypeException ( 'Cannot undefine primitive type `{{type}}`' , null , null , { type : typeDef . name } ) ; } validator = registry [ regKey ] && registry [ regKey ] . validator ; delete registry [ regKey ] ; return validator || false ; }


Input: Check value against type [CODESPLIT] function checkType ( type , value , previous , attributeName ) { var typeDef = parseTypeDef ( type ) ; var regKey = typeDef . name . toLocaleLowerCase ( ) ; validator = primitives [ regKey ] || ( registry [ regKey ] && registry [ regKey ] . validator ) ; if ( ! validator ) { throw TypeException ( 'Unknown type `{{type}}`' , null , [ attributeName ] , { type : typeDef . name } ) ; } else if ( typeDef . indexes ) { return arrayValidation ( typeDef , 0 , value , previous , attributeName , validator ) ; } return validator ( value , previous , attributeName ) ; }


Input: Return all defined type names [CODESPLIT] function getDefinedNames ( ) { return Object . keys ( primitives ) . concat ( Object . keys ( registry ) . map ( function ( type ) { return registry [ type ] . type ; } ) ) ; }


Input: ============= Validators ============= [CODESPLIT] function arrayValidation ( typeDef , index , value , previous , attributeName , validator ) { var indexInc ; var i ; var ilen ; if ( value === null || value === undefined || typeDef . indexes . length <= index ) { //console.log("Validating", value, index, typeDef); return validator ( value , previous , attributeName ) ; } else if ( typeDef . indexes . length > index ) { //console.log("Checking array", value, index, typeDef); if ( value instanceof Array ) { if ( value . length ) { indexInc = Math . max ( Math . floor ( value . length / VALIDATE_MAX_ARR_INDEX ) , 1 ) ; for ( i = 0 , ilen = value . length ; i < ilen ; i += indexInc ) { arrayValidation ( typeDef , index + 1 , value [ i ] , previous instanceof Array ? previous [ i ] : undefined , attributeName , validator ) ; } return value ; } else if ( previous instanceof Array && previous . length ) { indexInc = Math . max ( Math . floor ( value . length / VALIDATE_MAX_ARR_INDEX ) , 1 ) ; for ( i = 0 , ilen = value . length ; i < ilen ; i += indexInc ) { arrayValidation ( typeDef , index + 1 , null , previous [ i ] , attributeName , validator ) } return value ; } else { return arrayValidation ( typeDef , index + 1 , undefined , undefined , attributeName , validator ) } } } throw TypeException ( 'Invalid array for `{{type}}`' , null , [ attributeName ] , { type : typeDef . name , indexes : typeDef . indexes } ) ; }


Input: don t include redundant license or copyright notice [CODESPLIT] function ( comment ) { const isLicense = comment . toLowerCase ( ) . includes ( "license" ) || comment . toLowerCase ( ) . includes ( "copyright" ) ; if ( isLicense === false ) { return false ; } if ( lastLicense !== comment ) { lastLicense = comment ; return true ; } else { return false ; } }


Input: getter / setter [CODESPLIT] function ctor ( k , v ) { if ( k && _ . isString ( k ) && k . indexOf ( 'paths.' ) === 0 ) return get . apply ( null , _ . toArray ( arguments ) ) return v ? set ( k , v ) : get ( k ) }


Input: get setting key [CODESPLIT] function get ( k ) { if ( ! k ) return _SETTINGS let v = _ . get ( _SETTINGS , k ) if ( ! v ) return if ( _ . isString ( k ) && k . indexOf ( 'paths.' ) !== 0 ) return v let args = _ . drop ( _ . toArray ( arguments ) ) let argsLength = args . unshift ( v ) return path . join . apply ( path , args ) }


Input: set setting key with val ( merged if already exists and is plain object {} ) [CODESPLIT] function set ( k , v ) { let curr = get ( k ) if ( curr && _ . isPlainObject ( curr ) && _ . isPlainObject ( v ) ) v = _ . mcopy ( curr , v ) if ( k ) _ . set ( _SETTINGS , k , v ) if ( ! k ) _SETTINGS = v return get ( k ) }


Input: require src and merge with SETTINGS if exists [CODESPLIT] function load ( src ) { if ( ! src || ! _ . isString ( src ) ) return let file = _ . attempt ( require , src ) if ( ! file || _ . isError ( file ) || ! _ . isPlainObject ( file ) ) return return _ . merge ( _SETTINGS , file ) }


Input: Constructor [CODESPLIT] function SipFakeStack ( config ) { if ( ! config . server ) { throw '(SipFakeStack) You need at least to specify a valid IPv4/6 target' ; } this . server = config . server || null ; this . port = config . port || 5060 ; this . transport = config . transport || 'UDP' ; //    this.lport = config.lport || utils.randomPort(); this . lport = config . lport || null ; this . srcHost = config . srcHost ; this . timeout = config . timeout || 8000 ; this . wsPath = config . wsPath || null ; this . domain = config . domain || null ; this . onlyFirst = config . onlyFirst || true ; if ( net . isIPv6 ( config . server ) && ! config . srcHost ) { this . srcHost = utils . randomIP6 ( ) ; } else if ( ! config . srcHost ) { this . srcHost = utils . randomIP ( ) ; } }


Input: Test if size has a unit otherwise appends the passed unit string or the default for this Element . [CODESPLIT] function ( size , units ) { // Size set to a value which means "auto" if ( size === "" || size == "auto" || size === undefined || size === null ) { return size || '' ; } // Otherwise, warn if it's not a valid CSS measurement if ( Ext . isNumber ( size ) || this . numberRe . test ( size ) ) { return size + ( units || this . defaultUnit || 'px' ) ; } else if ( ! this . unitRe . test ( size ) ) { //<debug> Ext . Logger . warn ( "Warning, size detected (" + size + ") not a valid property value on Element.addUnits." ) ; //</debug> return size || '' ; } return size ; }


Input: Parses a number or string representing margin sizes into an object . Supports CSS - style margin declarations ( e . g . 10 10 10 10 10 10 10 and 10 10 10 10 are all valid options and would return the same result ) [CODESPLIT] function ( box ) { if ( typeof box != 'string' ) { box = box . toString ( ) ; } var parts = box . split ( ' ' ) , ln = parts . length ; if ( ln == 1 ) { parts [ 1 ] = parts [ 2 ] = parts [ 3 ] = parts [ 0 ] ; } else if ( ln == 2 ) { parts [ 2 ] = parts [ 0 ] ; parts [ 3 ] = parts [ 1 ] ; } else if ( ln == 3 ) { parts [ 3 ] = parts [ 1 ] ; } return { top : parts [ 0 ] || 0 , right : parts [ 1 ] || 0 , bottom : parts [ 2 ] || 0 , left : parts [ 3 ] || 0 } ; }


Input: Parses a number or string representing margin sizes into an object . Supports CSS - style margin declarations ( e . g . 10 10 10 10 10 10 10 and 10 10 10 10 are all valid options and would return the same result ) [CODESPLIT] function ( box , units ) { var me = this ; box = me . parseBox ( box ) ; return me . addUnits ( box . top , units ) + ' ' + me . addUnits ( box . right , units ) + ' ' + me . addUnits ( box . bottom , units ) + ' ' + me . addUnits ( box . left , units ) ; }


Input: Serializes a DOM form into a url encoded string [CODESPLIT] function ( form ) { var fElements = form . elements || ( document . forms [ form ] || Ext . getDom ( form ) ) . elements , hasSubmit = false , encoder = encodeURIComponent , name , data = '' , type , hasValue ; Ext . each ( fElements , function ( element ) { name = element . name ; type = element . type ; if ( ! element . disabled && name ) { if ( / select-(one|multiple) / i . test ( type ) ) { Ext . each ( element . options , function ( opt ) { if ( opt . selected ) { hasValue = opt . hasAttribute ? opt . hasAttribute ( 'value' ) : opt . getAttributeNode ( 'value' ) . specified ; data += Ext . String . format ( "{0}={1}&" , encoder ( name ) , encoder ( hasValue ? opt . value : opt . text ) ) ; } } ) ; } else if ( ! ( / file|undefined|reset|button / i . test ( type ) ) ) { if ( ! ( / radio|checkbox / i . test ( type ) && ! element . checked ) && ! ( type == 'submit' && hasSubmit ) ) { data += encoder ( name ) + '=' + encoder ( element . value ) + '&' ; hasSubmit = / submit / i . test ( type ) ; } } } } ) ; return data . substr ( 0 , data . length - 1 ) ; }


Input: Retrieves the document width [CODESPLIT] function ( ) { //<debug warn> Ext . Logger . deprecate ( "Ext.Element.getDocumentWidth() is no longer supported. " + "Please use Ext.Viewport#getWindowWidth() instead" , this ) ; //</debug> return Math . max ( ! Ext . isStrict ? document . body . scrollWidth : document . documentElement . scrollWidth , this . getViewportWidth ( ) ) ; }


Input: Retrieves the current orientation of the window . This is calculated by determining if the height is greater than the width . [CODESPLIT] function ( ) { //<debug warn> Ext . Logger . deprecate ( "Ext.Element.getOrientation() is no longer supported. " + "Please use Ext.Viewport#getOrientation() instead" , this ) ; //</debug> if ( Ext . supports . OrientationChange ) { return ( window . orientation == 0 ) ? 'portrait' : 'landscape' ; } return ( window . innerHeight > window . innerWidth ) ? 'portrait' : 'landscape' ; }


Input:
Creates new Sortable . [CODESPLIT] function ( el , config ) { config = config || { } ; Ext . apply ( this , config ) ; this . addEvents ( /**
             * @event sortstart
             * @param {Ext.Sortable} this
             * @param {Ext.event.Event} e
             */ 'sortstart' , /**
             * @event sortend
             * @param {Ext.Sortable} this
             * @param {Ext.event.Event} e
             */ 'sortend' , /**
             * @event sortchange
             * @param {Ext.Sortable} this
             * @param {Ext.Element} el The Element being dragged.
             * @param {Number} index The index of the element after the sort change.
             */ 'sortchange' // not yet implemented. // 'sortupdate', // 'sortreceive', // 'sortremove', // 'sortenter', // 'sortleave', // 'sortactivate', // 'sortdeactivate' ) ; this . el = Ext . get ( el ) ; this . callParent ( ) ; this . mixins . observable . constructor . call ( this ) ; if ( this . direction == 'horizontal' ) { this . horizontal = true ; } else if ( this . direction == 'vertical' ) { this . vertical = true ; } else { this . horizontal = this . vertical = true ; } this . el . addCls ( this . baseCls ) ; this . startEventName = ( this . getDelay ( ) > 0 ) ? 'taphold' : 'tapstart' ; if ( ! this . disabled ) { this . enable ( ) ; } }


Input: Enables sorting for this Sortable . This method is invoked immediately after construction of a Sortable unless the disabled configuration is set to true . [CODESPLIT] function ( ) { this . el . on ( this . startEventName , this . onStart , this , { delegate : this . itemSelector , holdThreshold : this . getDelay ( ) } ) ; this . disabled = false ; }


Input: MOVING SUM // FUNCTION : msum ( arr W [ options ] ) Computes a moving sum over an array . [CODESPLIT] function msum ( arr , W , options ) { var copy = true , clbk , len , sum , dropVal , out , i ; if ( ! isArray ( arr ) ) { throw new TypeError ( 'msum()::invalid input argument. Must provide an array. Value: `' + arr + '`.' ) ; } if ( ! isPositiveInteger ( W ) ) { throw new TypeError ( 'msum()::invalid input argument. Window must be a positive integer. Value: `' + W + '`.' ) ; } if ( arguments . length > 2 ) { if ( ! isObject ( options ) ) { throw new TypeError ( 'msum()::invalid input argument. Options must be an object. Value: `' + options + '`.' ) ; } if ( options . hasOwnProperty ( 'accessor' ) ) { clbk = options . accessor ; if ( ! isFunction ( clbk ) ) { throw new TypeError ( 'msum()::invalid option. Accessor option must be a function. Value: `' + clbk + '`.' ) ; } } if ( options . hasOwnProperty ( 'copy' ) ) { copy = options . copy ; if ( ! isBoolean ( copy ) ) { throw new TypeError ( 'msum()::invalid option. Copy option must be a boolean primitive. Value: `' + copy + '`.' ) ; } } } if ( W > arr . length ) { throw new Error ( 'msum()::invalid input argument. Window cannot exceed the array length.' ) ; } len = arr . length ; sum = 0 ; if ( copy && ! clbk ) { // Case 1: numeric array and return a copy... len = len - W + 1 ; out = new Array ( len ) ; // Calculate the sum for the first window... for ( i = 0 ; i < W ; i ++ ) { sum += arr [ i ] ; } out [ 0 ] = sum ; // Calculate sums for the remaining windows... for ( i = 0 ; i < len - 1 ; i ++ ) { sum += arr [ i + W ] - arr [ i ] ; out [ i + 1 ] = sum ; } return out ; } else if ( clbk ) { if ( copy ) { // Case 2: non-numeric array and return a copy... out = new Array ( len ) ; for ( i = 0 ; i < len ; i ++ ) { out [ i ] = clbk ( arr [ i ] ) ; } } else { // Case 3: non-numeric array and mutate the input array... out = arr ; for ( i = 0 ; i < len ; i ++ ) { out [ i ] = clbk ( arr [ i ] ) ; } } } else { // Case 4: numeric array and mutate the input array... out = arr ; } len = len - W + 1 ; // Calculate the sum for the first window... for ( i = 0 ; i < W ; i ++ ) { sum += out [ i ] ; } dropVal = out [ 0 ] ; out [ 0 ] = sum ; // Calculate sums for the remaining windows... for ( i = 1 ; i < len ; i ++ ) { sum += out [ i + W - 1 ] - dropVal ; dropVal = out [ i ] ; out [ i ] = sum ; } // Trim the output array: out . length = len ; return out ; }


Input: Take formatted options and creates an Express style req object . Takes an url String or an already parsed ( via . / lib / url . parse ) object . [CODESPLIT] function Request ( ghosttrain , route , url , options ) { // Headers info this . headers = options . headers || { } ; // Allows us to check protocol of client-side requests, // but relative requests won't have a protocol var protocol = 'window' in this ? window . location . protocol : '' ; // Expose URL properties var parsedURL = url . pathname ? url : parseURL ( url , true ) ; this . path = parsedURL . pathname ; this . query = parsedURL . query ; this . protocol = ( parsedURL . protocol || protocol ) . replace ( ':' , '' ) ; this . secure = this . protocol === 'https' ; this . route = route ; this . method = route . method . toUpperCase ( ) ; this . url = this . originalUrl = requestURL ( parsedURL ) ; this . params = route . params ; this . body = options . body || { } ; this . headers = options . headers || { } ; this . xhr = 'xmlhttprequest' === ( this . get ( 'X-Requested-With' ) || '' ) . toLowerCase ( ) ; }


Input: Patch for objects [CODESPLIT] function _compareMaps ( a , b , options ) { debug ( a , b ) ; let alength = a . size === undefined ? a . length : a . size ; let blength = b . size === undefined ? b . length : b . size ; if ( alength === 0 && blength === 0 ) return ops . NOP ; // ops.Map([...b]) and not just ops.Rpl(b) because if b is a map it's not good JSON. if ( alength === 0 || blength === 0 ) return new ops . Map ( [ ... b ] ) ; let patch = [ ] ; if ( ! options . sorted ) { a = Array . from ( a ) . sort ( ( a , b ) => utils . compare ( a , b , options ) ) ; b = Array . from ( b ) . sort ( ( a , b ) => utils . compare ( a , b , options ) ) ; } let ai = 1 , bi = 1 ; let ao = a [ 0 ] , bo = b [ 0 ] let element_options = options . getArrayElementOptions ( ) ; do { let comparison = utils . compare ( ao , bo , options ) ; debug ( "comparing items" , ao , bo , comparison ) ; if ( comparison < 0 ) { debug ( 'skip' ) ; ao = a [ ai ++ ] ; } else if ( comparison > 0 ) { debug ( 'insert' ) ; patch . push ( [ options . key ( bo ) , new ops . Ins ( options . value ( bo ) ) ] ) ; bo = b [ bi ++ ] ; } else { if ( options . value ( ao ) !== options . value ( bo ) ) { let element_patch = compare ( options . value ( ao ) , options . value ( bo ) , element_options ) if ( element_patch != ops . NOP ) patch . push ( [ options . key ( bo ) , element_patch ] ) ; } else debug ( 'skip2' ) ; ao = a [ ai ++ ] ; bo = b [ bi ++ ] ; } } while ( ai <= a . length && bi <= b . length ) ; while ( ai <= a . length ) { patch . push ( [ options . key ( ao ) , ops . DEL ] ) ; ao = a [ ai ++ ] ; } while ( bi <= b . length ) { patch . push ( [ options . key ( bo ) , new ops . Ins ( options . value ( bo ) ) ] ) ; bo = b [ bi ++ ] ; } return new ops . Map ( patch ) ; }


Input: Compare two object to produce a patch object . [CODESPLIT] function compare ( a , b , options ) { debug ( 'compare %j,%j options: %j' , a , b , options ) ; options = Options . addDefaults ( options ) ; debug ( 'compare - options %j' , options ) ; if ( a === b ) return ops . NOP ; if ( b === undefined ) return ops . DEL ; if ( a === undefined ) return new ops . Rpl ( b ) ; if ( typeof a === 'object' && typeof b === 'object' ) { if ( utils . isArrayLike ( a ) && utils . isArrayLike ( b ) ) { if ( options . map ) { return _compareMaps ( a , b , options ) ; } else { return _compareArrays ( a , b , options ) ; } } else if ( a instanceof Map && b instanceof Map ) { return _compareMaps ( a , b , options ) ; } else if ( a . constructor === b . constructor ) { // This isn't quite right, we can merge objects with a common base class return _compareObjects ( a , b , options ) ; } } return new ops . Rpl ( b ) ; }


Input: Convert over - the - wire JSON format back into typed patch object [CODESPLIT] function fromJSON ( object ) { if ( object instanceof ops . Op ) return object ; // If already patch, return it if ( object === undefined ) return ops . NOP ; if ( object . op ) { if ( object . op === ops . Rpl . name ) return new ops . Rpl ( object . data ) ; if ( object . op === ops . Ins . name ) return new ops . Ins ( object . data ) ; else if ( object . op === ops . NOP . name ) return ops . NOP ; else if ( object . op === ops . DEL . name ) return ops . DEL ; else if ( object . op === ops . Mrg . name ) return new ops . Mrg ( utils . map ( object . data , fromJSON ) ) ; else if ( object . op === ops . Map . name ) return new ops . Map ( object . data . map ( ( [ key , op ] ) => [ key , fromJSON ( op ) ] ) ) ; else if ( object . op === ops . Arr . name ) return new ops . Arr ( object . data . map ( ( [ key , op ] ) => [ key , fromJSON ( op ) ] ) ) ; else throw new Error ( 'unknown diff.op ' + object . op ) ; } else { return new ops . Rpl ( object ) ; } }


Input: Sorts the collection by a single sorter function . [CODESPLIT] function ( sorterFn ) { var me = this , items = me . items , keys = me . keys , length = items . length , temp = [ ] , i ; //first we create a copy of the items array so that we can sort it for ( i = 0 ; i < length ; i ++ ) { temp [ i ] = { key : keys [ i ] , value : items [ i ] , index : i } ; } Ext . Array . sort ( temp , function ( a , b ) { var v = sorterFn ( a . value , b . value ) ; if ( v === 0 ) { v = ( a . index < b . index ? - 1 : 1 ) ; } return v ; } ) ; //copy the temporary array back into the main this.items and this.keys objects for ( i = 0 ; i < length ; i ++ ) { items [ i ] = temp [ i ] . value ; keys [ i ] = temp [ i ] . key ; } me . fireEvent ( 'sort' , me , items , keys ) ; }


Input: Reorders each of the items based on a mapping from old index to new index . Internally this just translates into a sort . The sort event is fired whenever reordering has occured . [CODESPLIT] function ( mapping ) { var me = this , items = me . items , index = 0 , length = items . length , order = [ ] , remaining = [ ] , oldIndex ; me . suspendEvents ( ) ; //object of {oldPosition: newPosition} reversed to {newPosition: oldPosition} for ( oldIndex in mapping ) { order [ mapping [ oldIndex ] ] = items [ oldIndex ] ; } for ( index = 0 ; index < length ; index ++ ) { if ( mapping [ index ] == undefined ) { remaining . push ( items [ index ] ) ; } } for ( index = 0 ; index < length ; index ++ ) { if ( order [ index ] == undefined ) { order [ index ] = remaining . shift ( ) ; } } me . clear ( ) ; me . addAll ( order ) ; me . resumeEvents ( ) ; me . fireEvent ( 'sort' , me ) ; }


Input: TRANSPOSE // FUNCTION : transpose ( matrix [ options ] ) Computes the transpose of a matrix . [CODESPLIT] function transpose ( mat , options ) { /* jshint newcap:false */ var strides , shape , opts , ctor , err , tmp , d ; if ( ! isMatrixLike ( mat ) ) { throw new TypeError ( 'transpose()::invalid input argument. First argument must be a matrix. Value: `' + mat + '`.' ) ; } opts = { } ; if ( arguments . length > 1 ) { err = validate ( opts , options ) ; if ( err ) { throw err ; } } else { opts . copy = true ; } if ( opts . copy ) { // Copy the matrix data to a new typed array: ctor = ctors ( mat . dtype ) ; d = new ctor ( mat . data ) ; // Swap the dimensions: shape = [ mat . shape [ 1 ] , mat . shape [ 0 ] ] ; // Swap the strides: strides = [ mat . strides [ 1 ] , mat . strides [ 0 ] ] ; // Return a new matrix: return new mat . constructor ( d , mat . dtype , shape , mat . offset , strides ) ; } else { // Swap the dimensions... tmp = mat . shape [ 0 ] ; mat . shape [ 0 ] = mat . shape [ 1 ] ; mat . shape [ 1 ] = tmp ; // Swap the strides... tmp = mat . strides [ 0 ] ; mat . strides [ 0 ] = mat . strides [ 1 ] ; mat . strides [ 1 ] = tmp ; // Return the matrix transpose: return mat ; } }


Input: / * We use a queue to process events when we must handle the events sequentially [CODESPLIT] function Queue ( q ) { events . EventEmitter . call ( this ) ; var self = this ; this . q = q && q . process ? q : kue . createQueue ( ) ; this . q . process ( 'message' , function ( message , done ) { self . emit ( 'message' , message ) ; done ( ) ; } ) ; }


Input: Invoke . apply if value is a function otherwise return default value . [CODESPLIT] function apply ( func , args , self ) { return ( typeof func === 'function' ) ? func . apply ( self , array ( args ) ) : func }


Input: Following functions are not executed on import anymore [CODESPLIT] function detectDeviceClass ( ) { var body = document . body ; if ( isMobile . any ( ) ) { body . classList . add ( 'mobile' ) ; } if ( isMobile . Android ( ) ) { body . classList . add ( 'android' ) ; } if ( isTablet . any ( ) ) { body . classList . add ( 'tablet' ) ; } }


Input: This function can be triggered on window resize [CODESPLIT] function detectWindowWidth ( ) { var mobileWidth = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : 730 ; var isMobileWidth = window . innerWidth < mobileWidth ; var body = document . body ; if ( isMobileWidth ) { body . classList . add ( 'is-mobile-width' ) ; } else { body . classList . remove ( 'is-mobile-width' ) ; } }


Input: array of change stamps [CODESPLIT] function ( config , callback , scope ) { var changed = false ; if ( config ) { config . config_id = 'csv' ; Ext . data . CSV . superclass . constructor . call ( this , config ) ; if ( config . v ) { this . v = [ ] ; this . do_add ( config . v ) ; } } if ( this . v === undefined ) { this . v = [ ] ; changed = true ; } this . writeAndCallback ( changed , callback , scope ) ; }


Input: Checks if the schema s property at path is a ref - or an Array of refs - and if yes adds a virtual property suffixed with P which returns a promise to the reference s query result ( s ) . [CODESPLIT] function addVirtualRef ( schema , node , path ) { if ( _ . isArray ( node ) && isRef ( _ . first ( node ) ) ) { schema . virtual ( path + 'P' ) . get ( function ( ) { if ( ! this [ path ] || ! this [ path ] . length ) return Promise . resolve ( [ ] ) ; var model = this . constructor . db . model ( _ . first ( node ) . ref ) ; return findAsync . call ( model , { $or : _ . map ( this [ path ] , function ( id ) { return { _id : id } ; } ) } ) ; } ) ; } else if ( isRef ( node ) ) { schema . virtual ( path + 'P' ) . get ( function ( ) { var model = this . constructor . db . model ( node . ref ) ; return findByIdAsync . call ( model , this [ path ] ) ; } ) ; } }


Input: FUNCTIONS // FUNCTION : createTopic ( options ) Creates a new topic . [CODESPLIT] function createTopic ( options ) { var max = Number . MAX_VALUE , duplicates = false ; if ( ! options . hasOwnProperty ( 'max' ) ) { options . max = max ; } else { max = options . max ; } if ( ! options . hasOwnProperty ( 'duplicates' ) ) { options . duplicates = duplicates ; } else { duplicates = options . duplicates ; } if ( ! isInteger ( max ) || max < 0 ) { throw new TypeError ( 'createTopic()::invalid option. Max subscribers must be an integer greater than or equal to 0.' ) ; } if ( typeof duplicates !== 'boolean' ) { throw new TypeError ( 'createTopic()::invalid option. Duplicates flag must be a boolean.' ) ; } return { 'subscribers' : [ ] , 'options' : options } ; }


Input: loadModule - load module ( theme or plugin ) for app [CODESPLIT] function loadModule ( data , name ) { if ( typeof data !== 'object' ) { return ; } // Run before load module if ( typeof data . willLoad === 'function' ) { data . willLoad ( ) ; } // CSS Style if ( Array . isArray ( data . styles ) ) { data . styles . forEach ( function ( styles ) { theme . add ( styles , name ) ; } ) ; } else if ( typeof data . styles === 'object' ) { theme . add ( data . styles , name ) ; } // Components if ( data . components !== undefined ) { theme . addComponents ( data . components , name ) ; } // Layouts if ( data . layouts !== undefined ) { addLayout ( data . layouts ) ; } // I18n if ( data . i18n !== undefined ) { addTranslation ( data . i18n ) ; } // Redux actions if ( data . actions !== undefined ) { addActions ( data . actions ) ; } // Redux reducers if ( typeof data . reducers === 'function' ) { data . reducers ( ) ; } // Run after load module if ( typeof data . loaded === 'function' ) { data . loaded ( ) ; } }


Input: Workarounds based on findings by Jim Driscoll http : // weblogs . java . net / blog / driscoll / archive / 2009 / 09 / 08 / eval - javascript - global - context [CODESPLIT] function ( data ) { if ( data && jQuery . trim ( data ) ) { // We use execScript on Internet Explorer // We use an anonymous function so that context is window // rather than jQuery in Firefox ( window . execScript || function ( data ) { window [ "eval" ] . call ( window , data ) ; // jscs:ignore requireDotNotation } ) ( data ) ; } }


Input: Multifunctional method to get and set values of a collection The value / s can optionally be executed if it s a function [CODESPLIT] function ( elems , fn , key , value , chainable , emptyGet , raw ) { var i = 0 , length = elems . length , bulk = key == null ; // Sets many values if ( jQuery . type ( key ) === "object" ) { chainable = true ; for ( i in key ) { access ( elems , fn , i , key [ i ] , true , emptyGet , raw ) ; } // Sets one value } else if ( value !== undefined ) { chainable = true ; if ( ! jQuery . isFunction ( value ) ) { raw = true ; } if ( bulk ) { // Bulk operations run against the entire set if ( raw ) { fn . call ( elems , value ) ; fn = null ; // ...except when executing function values } else { bulk = fn ; fn = function ( elem , key , value ) { return bulk . call ( jQuery ( elem ) , value ) ; } ; } } if ( fn ) { for ( ; i < length ; i ++ ) { fn ( elems [ i ] , key , raw ? value : value . call ( elems [ i ] , i , fn ( elems [ i ] , key ) ) ) ; } } } return chainable ? elems : // Gets bulk ? fn . call ( elems ) : length ? fn ( elems [ 0 ] , key ) : emptyGet ; }


Input: Iterates over the standard event callback ( as well as the fancy multiple space - separated events change blur callback and jQuery - style event maps { event : callback } ) . [CODESPLIT] function ( iteratee , events , name , callback , opts ) { var i = 0 , names ; if ( name && typeof name === 'object' ) { // Handle event maps. if ( callback !== void 0 && 'context' in opts && opts . context === void 0 ) opts . context = callback ; for ( names = _ . keys ( name ) ; i < names . length ; i ++ ) { events = eventsApi ( iteratee , events , names [ i ] , name [ names [ i ] ] , opts ) ; } } else if ( name && eventSplitter . test ( name ) ) { // Handle space separated event names by delegating them individually. for ( names = name . split ( eventSplitter ) ; i < names . length ; i ++ ) { events = iteratee ( events , names [ i ] , callback , opts ) ; } } else { // Finally, standard events. events = iteratee ( events , name , callback , opts ) ; } return events ; }


Input: Splices insert into array at index at . [CODESPLIT] function ( array , insert , at ) { at = Math . min ( Math . max ( at , 0 ) , array . length ) ; var tail = Array ( array . length - at ) ; var length = insert . length ; for ( var i = 0 ; i < tail . length ; i ++ ) tail [ i ] = array [ i + at ] ; for ( i = 0 ; i < length ; i ++ ) array [ i + at ] = insert [ i ] ; for ( i = 0 ; i < tail . length ; i ++ ) array [ i + length + at ] = tail [ i ] ; }


Input: Remove a model or a list of models from the set . [CODESPLIT] function ( models , options ) { options = _ . extend ( { } , options ) ; var singular = ! _ . isArray ( models ) ; models = singular ? [ models ] : _ . clone ( models ) ; var removed = this . _removeModels ( models , options ) ; if ( ! options . silent && removed ) this . trigger ( 'update' , this , options ) ; return singular ? removed [ 0 ] : removed ; }


Input: Internal method called by both remove and set . [CODESPLIT] function ( models , options ) { var removed = [ ] ; for ( var i = 0 ; i < models . length ; i ++ ) { var model = this . get ( models [ i ] ) ; if ( ! model ) continue ; var index = this . indexOf ( model ) ; this . models . splice ( index , 1 ) ; this . length -- ; if ( ! options . silent ) { options . index = index ; model . trigger ( 'remove' , model , this , options ) ; } removed . push ( model ) ; this . _removeReference ( model , options ) ; } return removed . length ? removed : false ; }


Input: Does the pathname match the root? [CODESPLIT] function ( ) { var path = this . decodeFragment ( this . location . pathname ) ; var root = path . slice ( 0 , this . root . length - 1 ) + '/' ; return root === this . root ; }


Input: Ensures our PT array is in the correct sorted order ( by startTime ) [CODESPLIT] function ( ) { if ( ! performanceTimelineRequiresSort ) { return ; } // // Measures, which may be in this list, may enter the list in // an unsorted order. For example: // //  1. measure("a") //  2. mark("start_mark") //  3. measure("b", "start_mark") //  4. measure("c") //  5. getEntries() // // When calling #5, we should return [a,c,b] because technically the start time // of c is "0" (navigationStart), which will occur before b's start time due to the mark. // performanceTimeline . sort ( function ( a , b ) { return a . startTime - b . startTime ; } ) ; performanceTimelineRequiresSort = false ; }


Input: Cache management ---------------- Returns the template data associated with a template property string . Caches it in the process or retrieves it from the cache if already available . Returns undefined if there is no cacheable template data . [CODESPLIT] function getTemplateData ( templateProp , view , viewOptions ) { var data ; if ( templateProp && _ . isString ( templateProp ) ) { data = templateCache [ templateProp ] ; if ( ! data ) data = _createTemplateCache ( templateProp , view , viewOptions ) ; if ( data . invalid ) data = undefined ; if ( data ) data = _copyCacheEntry ( data ) ; } return data ; }


Input: Returns the template data associated with a given view provided that the template is set to a non - empty string . Otherwise it returns undefined . Manages caching behind the scenes . [CODESPLIT] function getViewTemplateData ( view , viewOptions ) { var data , meta = view . declarativeViews . meta ; if ( ! meta . processed ) { if ( view . template && _ . isString ( view . template ) ) { meta . originalTemplateProp = view . template ; data = getTemplateData ( view . template , view , viewOptions ) ; meta . processed = true ; meta . inGlobalCache = true ; if ( data ) events . trigger ( "cacheEntry:view:process" , _copyCacheEntry ( data ) , meta . originalTemplateProp , view , viewOptions ) ; } else { data = undefined ; meta . processed = true ; meta . inGlobalCache = false ; } } else { data = meta . inGlobalCache ? getTemplateData ( meta . originalTemplateProp , view , viewOptions ) : undefined ; } if ( data ) events . trigger ( "cacheEntry:view:fetch" , data , meta . originalTemplateProp , view , viewOptions ) ; return data ; }


Input: Clears the cache as a whole . [CODESPLIT] function clearCache ( fromMarionette ) { templateCache = { } ; if ( ! fromMarionette && Backbone . Marionette && Backbone . Marionette . TemplateCache ) Backbone . Marionette . TemplateCache . clear ( ) ; }


Input: Removes one or more cache entries . [CODESPLIT] function clearCachedTemplate ( templateProp ) { var fromMarionette = false , args = _ . toArray ( arguments ) , lastArg = _ . last ( args ) ; // When called from Marionette, or called recursively, the last argument is a "fromMarionette" boolean. Splice // it off before proceeding. if ( args . length && _ . isBoolean ( lastArg ) ) fromMarionette = args . pop ( ) ; // Handle multiple template props passed in as a varargs list, or as an array, with recursive calls for each // template property. if ( args . length > 1 ) { _ . each ( args , function ( singleProp ) { clearCachedTemplate ( singleProp , fromMarionette ) ; } ) ; } else if ( _ . isArray ( templateProp ) || _ . isArguments ( templateProp ) ) { _ . each ( templateProp , function ( singleProp ) { clearCachedTemplate ( singleProp , fromMarionette ) ; } ) ; } else { if ( ! templateProp ) throw new GenericError ( "Missing argument: string identifying the template. The string should be a template selector or the raw HTML of a template, as provided to the template property of a view when the cache entry was created" ) ; // Dealing with a single templateProp argument. // // Delete the corresponding cache entry. Try to clear it from the Marionette cache as well. The // templateProp must be a string - non-string arguments are quietly ignored. if ( _ . isString ( templateProp ) ) { _clearCachedTemplate ( templateProp ) ; if ( ! fromMarionette && Backbone . Marionette && Backbone . Marionette . TemplateCache ) { try { Backbone . Marionette . TemplateCache . clear ( templateProp ) ; } catch ( err ) { } } } } }


Input: Removes the template cache entry associated with a given view provided that a cache entry exists . [CODESPLIT] function clearViewTemplateCache ( view ) { var meta = view . declarativeViews . meta ; if ( meta . processed ) { if ( meta . inGlobalCache ) _clearCachedTemplate ( meta . originalTemplateProp ) ; } else if ( view . template && _ . isString ( view . template ) ) { _clearCachedTemplate ( view . template ) ; } }


Input: Defines the default template loader . Accepts a selector string and returns the template node ( usually a <script > or <template > node ) in a jQuery wrapper . [CODESPLIT] function loadTemplate ( templateProperty ) { var $template ; try { $template = $ ( templateProperty ) ; // If the template is not in the DOM, treat the template property as a raw template string instead. That // part is handled in `catch`, and should not be guarded against further errors here. To switch to that // process, just throw an error. if ( ! $ . contains ( document . documentElement , $template [ 0 ] ) ) throw new Error ( ) ; } catch ( err ) { $template = _wrapRawTemplate ( templateProperty ) ; // If the template string cannot be retrieved unaltered even after wrapping it in a script tag, bail out by // throwing a silent error (will be caught, and not propagated further, in _createTemplateCache()). if ( $template . html ( ) !== templateProperty ) throw new Error ( "Failed to wrap template string in script tag without altering it" ) ; } return $template ; }


Input: Takes a raw HTML / template string and wraps it in a script tag ( of type text / x - template ) . In the process it detects el - related data attributes which are contained in an HTML comment and sets them on the script tag . Returns the script element as a jQuery object . [CODESPLIT] function _wrapRawTemplate ( templateString ) { var $wrapper = $ ( "<script />" ) . attr ( "type" , "text/x-template" ) . text ( templateString ) , elDataAttributes = _getEmbeddedElAttributes ( templateString ) ; if ( elDataAttributes ) $wrapper . attr ( elDataAttributes ) ; return $wrapper ; }


Input: Takes a raw HTML / template string and looks for el - related data attributes which are contained in a comment . Returns the attributes hash or undefined if no attributes are found . [CODESPLIT] function _getEmbeddedElAttributes ( templateString ) { var elDataAttributes = { } , elDefinitionMatch = rxElDefinitionComment . exec ( templateString ) , elDefinitionComment = elDefinitionMatch && elDefinitionMatch [ 0 ] ; if ( elDefinitionComment ) { _ . each ( rxRegisteredDataAttributes , function ( rxAttributeMatcher , attributeName ) { var match = rxAttributeMatcher . exec ( elDefinitionComment ) , attributeValue = match && match [ 2 ] ; if ( attributeValue ) elDataAttributes [ attributeName ] = attributeValue ; } ) ; } return _ . size ( elDataAttributes ) ? elDataAttributes : undefined ; }


Input: Creates a copy of a cache entry and returns it . Protects the original cache entry from modification except for the _pluginData property which remains writable and can be accessed from the copy . [CODESPLIT] function _copyCacheEntry ( cacheEntry ) { var copy = _ . clone ( cacheEntry ) ; if ( _ . isObject ( copy . attributes ) ) copy . attributes = _ . clone ( copy . attributes ) ; return copy ; }


Input: Creates a cache entry for a given template property . [CODESPLIT] function _createTemplateCache ( templateProp , view , viewOptions ) { var $template , data , html , customLoader = Backbone . DeclarativeViews . custom . loadTemplate , defaultLoader = Backbone . DeclarativeViews . defaults . loadTemplate , modifiedDefaultLoader = defaultLoader !== loadTemplate , cacheId = templateProp ; // Load the template try { $template = customLoader ? customLoader ( templateProp , view , viewOptions ) : defaultLoader ( templateProp , view , viewOptions ) ; } catch ( err ) { // Rethrow and exit if the alarm has been raised deliberately, using an error type of Backbone.DeclarativeViews. if ( _isDeclarativeViewsErrorType ( err ) ) throw err ; // Otherwise, continue without having fetched a template. $template = "" ; } if ( ( customLoader || modifiedDefaultLoader ) && $template !== "" && ! ( $template instanceof Backbone . $ ) ) { throw new CustomizationError ( "Invalid return value. The " + ( customLoader ? "custom" : "default" ) + " loadTemplate function must return a jQuery instance, but it hasn't" ) ; } // Create cache entry if ( $template . length ) { // Read the el-related data attributes of the template. data = _getDataAttributes ( $template ) ; html = $template . html ( ) ; templateCache [ cacheId ] = { html : html , compiled : _tryCompileTemplate ( html , $template ) , tagName : data . tagName , className : data . className , id : data . id , attributes : data . attributes , // Data store for plugins. Plugins should create their own namespace in the store, with the plugin name // as key. _pluginData : { } } ; events . trigger ( "cacheEntry:create" , templateCache [ cacheId ] , templateProp , view , viewOptions ) ; } else { templateCache [ cacheId ] = { invalid : true } ; } return templateCache [ cacheId ] ; }


Input: Returns the compiled template if a custom compiler is set in Backbone . DeclarativeViews . custom . compiler or undefined if no compiler is set . [CODESPLIT] function _tryCompileTemplate ( html , $template ) { var compiled , customCompiler = Backbone . DeclarativeViews . custom . compiler ; if ( customCompiler ) { if ( customCompiler && ! _ . isFunction ( customCompiler ) ) throw new CustomizationError ( "Invalid custom template compiler set in Backbone.DeclarativeViews.custom.compiler: compiler is not a function" ) ; try { compiled = customCompiler ( html , $template ) ; } catch ( err ) { throw new CompilerError ( 'An error occurred while compiling the template. The compiler had been passed the HTML string "' + html + ( $template ? '" as the first argument, and the corresponding template node, wrapped in a jQuery object, as the second argument.' : '" as the only argument.' ) + "\nOriginal error thrown by the compiler:\n" + err . message ) ; } } return compiled ; }


Input: Adds a name to the list of data attributes which are used and managed by Backbone . Declarative . Views . The name must be passed without the data - prefix but written as in the data attribute ( ie tag - name not tagName ) . [CODESPLIT] function _registerDataAttribute ( name , options ) { var existingNames = _getRegisteredDataAttributeNames ( ) , fullName = "data-" + name , type = options && options . isJSON ? "json" : "primitives" , names = registeredDataAttributes [ type ] ; if ( name . indexOf ( "data-" ) === 0 ) throw new CustomizationError ( 'registerDataAttribute(): Illegal attribute name "' + name + '", must be registered without "data-" prefix' ) ; if ( name === "html" || name === "compiled" ) throw new CustomizationError ( 'registerDataAttribute(): Cannot register attribute name "' + name + '" because it is reserved' ) ; if ( _ . contains ( existingNames , name ) ) throw new CustomizationError ( 'registerDataAttribute(): Cannot register attribute name "' + name + '" because it has already been registered' ) ; // Add the name to the list of registered data attributes names . push ( name ) ; registeredDataAttributes [ type ] = _ . uniq ( names ) ; // Create amd store a regex matching the attribute and its value in an HTML/template string, for transfer onto a // wrapper node (see _wrapRawTemplate()) rxRegisteredDataAttributes [ fullName ] = new RegExp ( fullName + "\\s*=\\s*(['\"])([\\s\\S]+?)\\1" ) ; // Update the regular expression which tests an HTML/template string and detects a comment containing registered // attributes. rxElDefinitionComment = _createElDefinitionCommentRx ( ) ; }