Input:
Builds the table UI with all current node data and associates the active events on each row . [CODESPLIT] function updateTableUI ( ) { var table = $ ( '.control-table tbody' ) ; table . off ( 'mouseenter' , 'tr' , onControlTableRowMouseOver ) ; table . off ( 'mouseleave' , 'tr' , onControlTableRowMouseOver ) ; table . off ( 'contextmenu' , 'tr' , onControlTableRowContextClick ) ; table . empty ( ) ; if ( data ) { data . nodes . forEach ( function ( node ) { var nd = node . packageData ; var name = appOptions . showFullNames ? nd . actualPackageName : nd . packageName ; var isAliased = nd . isAlias ? ' isAliased' : '' ; var tr = $ ( '
' + '' + name + '	' + '' + nd . jspmType + '	' + '' + nd . version + '	' + '' + node . minLevel + '	' + '
' ) ; table . append ( tr ) ; tr . on ( 'mouseenter' , onControlTableRowMouseOver . bind ( this , nodes , links , node , true ) ) ; tr . on ( 'mouseleave' , onControlTableRowMouseOver . bind ( this , nodes , links , node , false ) ) ; tr . on ( 'contextmenu' , onControlTableRowContextClick . bind ( this , node ) ) ; } ) ; // Removes sort order for any header and signals update for new data $ ( '#nodeTable th' ) . removeClass ( 'headerSortDown' ) ; $ ( '#nodeTable th' ) . removeClass ( 'headerSortUp' ) ; $ ( '#nodeTable' ) . trigger ( 'update' ) ; updateTableUIExtent ( ) ; } }


Input: Updates the node table max - height enabling scrolling as necessary . [CODESPLIT] function updateTableUIExtent ( ) { var tableDiv = $ ( '.control-table-inner' ) ; var nodeTable = $ ( '#nodeTable' ) ; var tableHeight = nodeTable . height ( ) ; var offset = tableDiv . offset ( ) ; var maxTableHeight = window . innerHeight - offset . top - 20 ; tableDiv . css ( 'max-height' , maxTableHeight ) ; nodeTable . css ( 'margin-right' , tableHeight > maxTableHeight ? '10px' : '0px' ) ; }


Input: Determines a new scale that fits the entire graph into view . [CODESPLIT] function zoomFit ( ) { var bounds = graph . node ( ) . getBBox ( ) ; var parent = graph . node ( ) . parentElement ; var fullWidth = parent . clientWidth , fullHeight = parent . clientHeight ; var width = bounds . width , height = bounds . height ; if ( width === 0 || height === 0 ) { return 1 ; } // nothing to fit var scale = 0.75 / Math . max ( width / fullWidth , height / fullHeight ) ; scale = Math . max ( Math . min ( scale , maxScaleExtent ) , minScaleExtent ) ; return scale ; }


Input: Get the the inner width of the browser window [CODESPLIT] function getWindowWidth ( ) { if ( window . innerWidth ) { return window . innerWidth ; } else if ( document . documentElement . clientWidth ) { return document . documentElement . clientWidth ; } else if ( document . body . clientWidth ) { return document . body . clientWidth ; } else { return 0 ; } }


Input:
Adds link to CSS in the head if no CSS is loaded [CODESPLIT] function ( cssScreen , cssHandheld , mobileMaxWidth ) { // Set config values
 if ( typeof ( cssScreen ) != "undefined" ) { config . cssScreen = cssScreen ; } if ( typeof ( cssHandheld ) != "undefined" ) { config . cssHandheld = cssHandheld ; } if ( typeof ( mobileMaxWidth ) != "undefined" ) { config . mobileMaxWidth = mobileMaxWidth ; } // Check if CSS is loaded
 var cssloadCheckNode = document . createElement ( 'div' ) ; cssloadCheckNode . className = config . testDivClass ; document . getElementsByTagName ( "body" ) [ 0 ] . appendChild ( cssloadCheckNode ) ; if ( cssloadCheckNode . offsetWidth != 100 && noMediaQuery == false ) { noMediaQuery = true ; } cssloadCheckNode . parentNode . removeChild ( cssloadCheckNode ) if ( noMediaQuery == true ) { // Browser does not support Media Queries, so JavaScript will supply a fallback
 var cssHref = "" ; // Determines what CSS file to load
 if ( getWindowWidth ( ) <= config . mobileMaxWidth ) { cssHref = config . cssHandheld ; newCssMediaType = "handheld" ; } else { cssHref = config . cssScreen ; newCssMediaType = "screen" ; } // Add CSS link to <head> of page
 if ( cssHref != "" && currentCssMediaType != newCssMediaType ) { var currentCssLinks = document . styleSheets for ( var i = 0 ; i < currentCssLinks . length ; i ++ ) { for ( var ii = 0 ; ii < currentCssLinks [ i ] . media . length ; ii ++ ) { if ( typeof ( currentCssLinks [ i ] . media ) == "object" ) { if ( currentCssLinks [ i ] . media . item ( ii ) == "fallback" ) { currentCssLinks [ i ] . ownerNode . parentNode . removeChild ( currentCssLinks [ i ] . ownerNode ) i -- break ; } } else { if ( currentCssLinks [ i ] . media . indexOf ( "fallback" ) >= 0 ) { currentCssLinks [ i ] . owningElement . parentNode . removeChild ( currentCssLinks [ i ] . owningElement ) i -- break ; } } } } if ( typeof ( cssHref ) == "object" ) { for ( var i = 0 ; i < cssHref . length ; i ++ ) { addCssLink ( cssHref [ i ] ) } } else { addCssLink ( cssHref ) } currentCssMediaType = newCssMediaType ; } // Check screen size again if user resizes window
 addEvent ( window , wbos . CssTools . MediaQueryFallBack . LoadCssDelayed , 'onresize' ) } }


Input: Plugin level function ( dealing with files ) [CODESPLIT] function gulpRebound ( options ) { options || ( options = { } ) ; // Creating a stream through which each file will pass return through . obj ( function ( file , enc , cb ) { // return empty file if ( file . isNull ( ) ) return cb ( null , file ) ; if ( file . isStream ( ) ) { throw new PluginError ( PLUGIN_NAME , "Gulp Rebound doesn't handle streams!" ) ; } // Compile try { file . contents = new Buffer ( rebound ( file . contents . toString ( enc ) , { name : file . path , baseDest : options . baseUrl || '' } ) . src , enc ) ; gutil . log ( gutil . colors . green ( 'File ' + file . relative + ' compiled' ) ) ; file . path = file . path . replace ( '.html' , '.js' ) ; } catch ( err ) { gutil . log ( gutil . colors . red ( 'Error in ' + file . relative ) ) ; gutil . log ( err ) ; } cb ( null , file ) ; } ) ; }


Input: / * Utils . clear () If folder exist clear files inside Else create it [CODESPLIT] function clearFile ( obj ) { if ( Utils . tools . isArray ( obj ) ) obj . forEach ( _clearFile ) ; else _clearFile ( obj ) ; return Utils ; }


Input: / * [CODESPLIT] function Item ( source , file ) { this . source = source ; this . file = file ; this . dirname = path . dirname ( this . file ) ; this . basename = path . basename ( this . file , '.yml' ) ; this . relPath = path . relative ( this . source , this . dirname ) ; this . yaml = yaml . load ( fs . readFileSync ( this . file , 'utf8' ) ) ; this [ "package" ] = path . dirname ( this . relPath ) ; this . module = path . basename ( this . relPath ) ; }


Input: Sends successful HTTP reply [CODESPLIT] function do_success ( req , res , msg ) { res . writeHead ( 200 , { 'Content-Type' : ( ( typeof msg === 'string' ) ? 'text/plain' : 'application/json' ) } ) ; msg = ( typeof msg === 'string' ) ? msg : helpers . stringify ( msg ) ; res . end ( msg ) ; }


Input: Sends failed HTTP reply [CODESPLIT] function do_failure ( req , res , opts ) { opts = opts || { } ; var obj = { 'type' : opts . type || 'error' , 'code' : opts . code || 501 , 'desc' : opts . desc || ( '' + opts ) } ; res . writeHead ( obj . code , { 'Content-Type' : 'application/json' } ) ; res . end ( helpers . stringify ( obj ) + '\n' ) ; }


Input: Builder for generic HTTP Request Handler [CODESPLIT] function do_create_req ( config , routes ) { routes = routes || { } ; var version = routes . version || { } ; if ( version && ( typeof version === 'object' ) ) { } else { version = { 'self' : routes . version || config . pkg . version } ; } if ( ! version . api ) { version . api = api_config . pkg . version ; } routes . version = version ; var router = new RequestRouter ( routes ) ; var req_counter = 0 ; /* Inner Request handler */ function do_req ( req , res ) { req_counter += 1 ; return router . resolve ( req , res ) ; } // do_req return do_req ; }


Input: HTTP Server Creation [CODESPLIT] function do_create_server ( config , do_req ) { var http = require ( 'http' ) ; if ( config . host ) { http . createServer ( do_req ) . listen ( config . port , config . host ) ; //console.log("Server running at http://"+config.host+":"+config.port+"/"); } else { http . createServer ( do_req ) . listen ( config . port ) ; //console.log("Server running at http://0.0.0.0:"+config.port); } return http ; }


Input: API server builder [CODESPLIT] function setup_server ( config , opts ) { config . _def ( 'port' , 3000 ) ; var req_handler = do_create_req ( config , opts ) ; var server = do_create_server ( config , function ( req , res ) { req_handler ( req , res ) . then ( function ( obj ) { if ( obj === api . replySent ) { // Silently return since reply has been handler already. return ; } else if ( obj === api . notFound ) { do_failure ( req , res , { 'verb' : 'notFound' , 'desc' : 'The requested resource could not be found.' , 'code' : 404 } ) ; } else { do_success ( req , res , obj ) ; } } ) . fail ( function ( err ) { do_failure ( req , res , err ) ; if ( ! ( err instanceof errors . HTTPError ) ) { require ( 'prettified' ) . errors . print ( err ) ; } } ) . done ( ) ; } ) ; return server ; }


Input: Cross - browser event listener [CODESPLIT] function ( element , ev , fn ) { if ( element . addEventListener ) element . addEventListener ( ev , fn , false ) ; else element . attachEvent ( "on" + ev , fn ) ; }


Input: // FIXME : make SuggestBox work for multiple documents . [CODESPLIT] function ( ) { if ( this . visible ( ) ) return ; this . _bodyElement = document . body ; this . _bodyElement . addEventListener ( "mousedown" , this . _maybeHideBound , true ) ; this . _overlay = new WebInspector . SuggestBox . Overlay ( ) ; this . _overlay . setContentElement ( this . _container ) ; }


Input: Initialize a new Reply with the given parent and definition . [CODESPLIT] function Reply ( parent , definition ) { var key ; for ( key in updateMixin ) { this [ key ] = updateMixin [ key ] ; } Reply . super_ . apply ( this , arguments ) ; }


Input: --- class / interfaces ---------------------------------- --- implements ------------------------------------------ [CODESPLIT] function WMURL_decode ( source ) { // @arg String - percent encoded string. // @ret String - decode string. // @throws Error("invalid WMURL.decode") // @desc decodeURIComponent impl. //{@dev $valid ( $type ( source , "String" ) , WMURL_decode , "source" ) ; //}@dev return source . replace ( / (%[\da-f][\da-f])+ / g , function ( match ) { var rv = [ ] ; var ary = match . split ( "%" ) . slice ( 1 ) , i = 0 , iz = ary . length ; var a = 0 , b = 0 , c = 0 ; // UTF-8 bytes for ( ; i < iz ; ++ i ) { a = parseInt ( ary [ i ] , 16 ) ; if ( a !== a ) { // isNaN(a) throw new Error ( "invalid WMURL.decode" ) ; } // decode UTF-8 if ( a < 0x80 ) { // ASCII(0x00 ~ 0x7f) rv . push ( a ) ; } else if ( a < 0xE0 ) { b = parseInt ( ary [ ++ i ] , 16 ) ; rv . push ( ( a & 0x1f ) << 6 | ( b & 0x3f ) ) ; } else if ( a < 0xF0 ) { b = parseInt ( ary [ ++ i ] , 16 ) ; c = parseInt ( ary [ ++ i ] , 16 ) ; rv . push ( ( a & 0x0f ) << 12 | ( b & 0x3f ) << 6 | ( c & 0x3f ) ) ; } } return String . fromCharCode . apply ( null , rv ) ; } ) ; }


Input: Returns a Buffer of the specified file from the specified repo and commit reference . Recursively gets the tree instances until the last part which is gets the rawObject for and serves back over HTTP . [CODESPLIT] function serveGitFile ( repo , tree , parts , res , next ) { //console.log("Serving git file: " + parts); var thisPart = parts . shift ( ) ; var isLastPart = parts . length === 0 ; var entryIndex = - 1 ; for ( var i = 0 ; i < tree . entries . length ; i ++ ) { if ( tree . entries [ i ] . name === thisPart ) { entryIndex = i ; break ; } } if ( entryIndex < 0 ) return next ( ) ; var entry = tree . entries [ entryIndex ] ; if ( isLastPart ) { repo . getBlob ( entry . id , function ( err , buf ) { if ( err ) return next ( err ) ; if ( ! buf . data ) return next ( ) ; serveBuffer ( buf . data , res , thisPart ) ; } ) ; } else { repo . getTree ( entry . id , function ( err , entryTree ) { if ( err ) return next ( err ) ; serveGitFile ( repo , entryTree , parts , res , next ) ; } ) ; } }


Input: ////////////////////////////////////////////////////////////////////////// [CODESPLIT] function buildAndStart ( ) { if ( / ^https?:\/\/ / . test ( Program . file ) ) { var url = Program . file . replace ( / ^(https?:\/\/)([^/:]+)(?=:\d+|\/) / , function ( m , a , b ) { if ( ! / \d+\.\d+\.\d+\.\d+ / . test ( a ) ) { return a + Hosts . findRealHost ( b ) ; } else { return m ; } } ) ; Config . entryBundleUrl = url ; startServerAndLaunchDevtool ( ) ; } else { var filePath = Path . resolve ( Program . file ) ; var ext = Path . extname ( filePath ) ; if ( ! Fs . existsSync ( filePath ) ) { console . error ( filePath + ': No such file or directory' ) ; return Exit ( 0 ) ; } if ( ext == '.ju' || ext == '.vue' ) { console . log ( 'building...' ) ; console . time ( 'Build completed!' ) ; buildFileAndWatchIt ( Program . mode , filePath ) . then ( function ( ) { console . timeEnd ( 'Build completed!' ) ; startServerAndLaunchDevtool ( Program . file ) ; } , function ( err ) { if ( err ) { console . log ( err , err . stack ) ; } Exit ( 0 ) ; } ) } else if ( ext == '.js' ) { buildFileAndWatchIt ( 'copy' , filePath ) . then ( function ( ) { startServerAndLaunchDevtool ( Program . file ) ; } ) } else if ( ! ext ) { //处理目录 if ( Fs . statSync ( filePath ) . isDirectory ( ) ) { Config . root = filePath ; startServerAndLaunchDevtool ( Program . entry ) } else { console . error ( Program . file + ' is not a directory!' ) ; Exit ( 0 ) ; } } else { console . error ( 'Error:unsupported file type: ' , ext ) ; return Exit ( 0 ) ; } } }


Input: @function randomUniqueId [CODESPLIT] function randomUniqueId ( ) { // increment count of generated ids randomUniqueId . count ++ // get timestamp var timestamp = microTimestamp ( ) // create unique id randomUniqueId . id = crypto . createHash ( 'sha256' ) // process id, microsec timestamp, and counter . update ( randomUniqueId . processId + randomUniqueId . id + timestamp + randomUniqueId . count ) // get hash as hex . digest ( 'hex' ) // only get 128 bits . substring ( 0 , 32 ) // return object with id and timestamp return { id : randomUniqueId . id , timestamp , } }


Input: The Callback to start editing the next / previous property / selector . [CODESPLIT] function moveToNextCallback ( alreadyNew , valueChanged , section ) { if ( ! moveDirection ) return ; // User just tabbed through without changes. if ( moveTo && moveTo . parent ) { moveTo . startEditing ( ! isEditingName ? moveTo . nameElement : moveTo . valueElement ) ; return ; } // User has made a change then tabbed, wiping all the original treeElements. // Recalculate the new treeElement for the same property we were going to edit next. if ( moveTo && ! moveTo . parent ) { var rootElement = section . propertiesTreeOutline . rootElement ( ) ; if ( moveDirection === "forward" && blankInput && ! isEditingName ) -- moveToIndex ; if ( moveToIndex >= rootElement . childCount ( ) && ! this . _newProperty ) createNewProperty = true ; else { var treeElement = moveToIndex >= 0 ? rootElement . childAt ( moveToIndex ) : null ; if ( treeElement ) { var elementToEdit = ! isEditingName || isPropertySplitPaste ? treeElement . nameElement : treeElement . valueElement ; if ( alreadyNew && blankInput ) elementToEdit = moveDirection === "forward" ? treeElement . nameElement : treeElement . valueElement ; treeElement . startEditing ( elementToEdit ) ; return ; } else if ( ! alreadyNew ) moveToSelector = true ; } } // Create a new attribute in this section (or move to next editable selector if possible). if ( createNewProperty ) { if ( alreadyNew && ! valueChanged && ( isEditingName ^ ( moveDirection === "backward" ) ) ) return ; section . addNewBlankProperty ( ) . startEditing ( ) ; return ; } if ( abandonNewProperty ) { moveTo = this . _findSibling ( moveDirection ) ; var sectionToEdit = ( moveTo || moveDirection === "backward" ) ? section : section . nextEditableSibling ( ) ; if ( sectionToEdit ) { if ( sectionToEdit . style ( ) . parentRule ) sectionToEdit . startEditingSelector ( ) ; else sectionToEdit . _moveEditorFromSelector ( moveDirection ) ; } return ; } if ( moveToSelector ) { if ( section . style ( ) . parentRule ) section . startEditingSelector ( ) ; else section . _moveEditorFromSelector ( moveDirection ) ; } }


Input: Processes a list of files and produces the api routing for them [CODESPLIT] function processFileList ( files , base , settings , state ) { for ( var i = 0 ; i < files . length ; i ++ ) { var modulePath = path . join ( base , files [ i ] ) ; var stats = fs . statSync ( modulePath ) ; if ( stats . isFile ( ) ) { // Try to load the module var module = require ( modulePath ) ; var relative = path . relative ( settings . source , modulePath ) ; __log ( 'Relative path: %s' , relative ) ; var pathWithoutExtension = relative . substr ( 0 , relative . lastIndexOf ( '.' ) ) ; var routeName = pathWithoutExtension . replace ( / \\ / g , '/' ) . replace ( / \. / g , '_' ) ; var isRoot = new RegExp ( settings . rootModule + '/?$' , 'g' ) . test ( routeName ) ; var routePath = routeName ; // Special case for an index file - put these in the root of the api             if ( isRoot ) { if ( routePath . lastIndexOf ( '/' ) > - 1 ) routePath = routePath . substr ( 0 , routePath . lastIndexOf ( '/' ) ) ; else routePath = undefined ; } __log ( '%s (%s)' , routeName , routePath ) ; var apiPath = utils . combineApiPath ( settings . root , routePath ) ; state . endpoints [ routeName ] = { baseUrl : apiPath , filename : modulePath , routeName : routeName } ; __log ( state . endpoints [ routeName ] ) ; settings . app . use ( apiPath , module ) ; } else if ( stats . isDirectory ( ) ) { var dirFiles = fs . readdirSync ( modulePath ) ; processFileList ( dirFiles , modulePath , settings , state ) ; } } }


Input: package module for different environments [CODESPLIT] function packageModule ( global , name , api ) { if ( global . define && global . define . amd ) { define ( [ ] , api ) ; } else if ( typeof exports !== "undefined" ) { module . exports = api ; } else { global [ name ] = api ; } }


Input:
/ * frameworkEventListeners fetcher functions should produce following output : { framework event listeners eventListeners : [ { handler : function () useCapture : true passive : false type : change remove : function ( type handler useCapture passive ) } ... ] internal framework event handlers internalHandlers : [ function () function () ... ] } [CODESPLIT] function frameworkEventListeners ( ) { var errorLines = [ ] ; var eventListeners = [ ] ; var internalHandlers = [ ] ; var fetchers = [ jQueryFetcher ] ; try { if ( self . devtoolsFrameworkEventListeners && isArrayLike ( self . devtoolsFrameworkEventListeners ) ) fetchers = fetchers . concat ( self . devtoolsFrameworkEventListeners ) ; } catch ( e ) { errorLines . push ( "devtoolsFrameworkEventListeners call produced error: " + toString ( e ) ) ; } for ( var i = 0 ; i < fetchers . length ; ++ i ) { try { var fetcherResult = fetchers [ i ] ( this ) ; if ( fetcherResult . eventListeners && isArrayLike ( fetcherResult . eventListeners ) ) { eventListeners = eventListeners . concat ( fetcherResult . eventListeners . map ( checkEventListener ) . filter ( nonEmptyObject ) ) ; } if ( fetcherResult . internalHandlers && isArrayLike ( fetcherResult . internalHandlers ) ) internalHandlers = internalHandlers . concat ( fetcherResult . internalHandlers . map ( checkInternalHandler ) . filter ( nonEmptyObject ) ) ; } catch ( e ) { errorLines . push ( "fetcher call produced error: " + toString ( e ) ) ; } } var result = { eventListeners : eventListeners } ; if ( internalHandlers . length ) result . internalHandlers = internalHandlers ; if ( errorLines . length ) { var errorString = "Framework Event Listeners API Errors:\n\t" + errorLines . join ( "\n\t" ) ; errorString = errorString . substr ( 0 , errorString . length - 1 ) ; result . errorString = errorString ; } return result ; /**
         * @param {?Object} obj
         * @return {boolean}
         */ function isArrayLike ( obj ) { if ( ! obj || typeof obj !== "object" ) return false ; try { if ( typeof obj . splice === "function" ) { var len = obj . length ; return typeof len === "number" && ( len >>> 0 === len && ( len > 0 || 1 / len > 0 ) ) ; } } catch ( e ) { } return false ; } /**
         * @param {*} eventListener
         * @return {?WebInspector.EventListenerObjectInInspectedPage}
         */ function checkEventListener ( eventListener ) { try { var errorString = "" ; if ( ! eventListener ) errorString += "empty event listener, " ; var type = eventListener . type ; if ( ! type || ( typeof type !== "string" ) ) errorString += "event listener's type isn't string or empty, " ; var useCapture = eventListener . useCapture ; if ( typeof useCapture !== "boolean" ) errorString += "event listener's useCapture isn't boolean or undefined, " ; var passive = eventListener . passive ; if ( typeof passive !== "boolean" ) errorString += "event listener's passive isn't boolean or undefined, " ; var handler = eventListener . handler ; if ( ! handler || ( typeof handler !== "function" ) ) errorString += "event listener's handler isn't a function or empty, " ; var remove = eventListener . remove ; if ( remove && ( typeof remove !== "function" ) ) errorString += "event listener's remove isn't a function, " ; if ( ! errorString ) { return { type : type , useCapture : useCapture , passive : passive , handler : handler , remove : remove } ; } else { errorLines . push ( errorString . substr ( 0 , errorString . length - 2 ) ) ; return null ; } } catch ( e ) { errorLines . push ( toString ( e ) ) ; return null ; } } /**
         * @param {*} handler
         * @return {function()|null}
         */ function checkInternalHandler ( handler ) { if ( handler && ( typeof handler === "function" ) ) return handler ; errorLines . push ( "internal handler isn't a function or empty" ) ; return null ; } /**
         * @param {*} obj
         * @return {string}
         * @suppress {uselessCode}
         */ function toString ( obj ) { try { return "" + obj ; } catch ( e ) { return "<error>" ; } } /**
         * @param {*} obj
         * @return {boolean}
         */ function nonEmptyObject ( obj ) { return ! ! obj ; } function jQueryFetcher ( node ) { if ( ! node || ! ( node instanceof Node ) ) return { eventListeners : [ ] } ; var jQuery = /** @type {?{fn,data,_data}}*/ ( window [ "jQuery" ] ) ; if ( ! jQuery || ! jQuery . fn ) return { eventListeners : [ ] } ; var jQueryFunction = /** @type {function(!Node)} */ ( jQuery ) ; var data = jQuery . _data || jQuery . data ; var eventListeners = [ ] ; var internalHandlers = [ ] ; if ( typeof data === "function" ) { var events = data ( node , "events" ) ; for ( var type in events ) { for ( var key in events [ type ] ) { var frameworkListener = events [ type ] [ key ] ; if ( typeof frameworkListener === "object" || typeof frameworkListener === "function" ) { var listener = { handler : frameworkListener . handler || frameworkListener , useCapture : true , passive : false , type : type } ; listener . remove = jQueryRemove . bind ( node , frameworkListener . selector ) ; eventListeners . push ( listener ) ; } } } var nodeData = data ( node ) ; if ( nodeData && typeof nodeData . handle === "function" ) internalHandlers . push ( nodeData . handle ) ; } var entry = jQueryFunction ( node ) [ 0 ] ; if ( entry ) { var entryEvents = entry [ "$events" ] ; for ( var type in entryEvents ) { var events = entryEvents [ type ] ; for ( var key in events ) { if ( typeof events [ key ] === "function" ) { var listener = { handler : events [ key ] , useCapture : true , passive : false , type : type } ; // We don't support removing for old version < 1.4 of jQuery because it doesn't provide API for getting "selector". eventListeners . push ( listener ) ; } } } if ( entry && entry [ "$handle" ] ) internalHandlers . push ( entry [ "$handle" ] ) ; } return { eventListeners : eventListeners , internalHandlers : internalHandlers } ; } /**
         * @param {string} selector
         * @param {string} type
         * @param {function()} handler
         * @this {?Object}
         */ function jQueryRemove ( selector , type , handler ) { if ( ! this || ! ( this instanceof Node ) ) return ; var node = /** @type {!Node} */ ( this ) ; var jQuery = /** @type {?{fn,data,_data}}*/ ( window [ "jQuery" ] ) ; if ( ! jQuery || ! jQuery . fn ) return ; var jQueryFunction = /** @type {function(!Node)} */ ( jQuery ) ; jQueryFunction ( node ) . off ( type , selector , handler ) ; } }


Input: Returns a proxy for the given { [CODESPLIT] function proxify ( api ) { if ( ! api || typeof api !== "object" ) throw new TypeError ( "Only objects can be proxified." ) ; if ( typeof api . route !== "function" || typeof api . close !== "function" ) throw new TypeError ( "Only objects that offer an owe Api interface can be proxified." ) ; const passthroughSet = api [ passthrough ] ; const proxy = new Proxy ( target , { get ( target , property ) { if ( typeof property === "symbol" || passthroughSet && passthroughSet . has ( property ) && property in api ) return typeof api [ property ] === "function" ? api [ property ] . bind ( api ) : api [ property ] ; return proxify ( api . route ( property ) ) ; } , apply ( target , context , args ) { return api . close ( args [ 0 ] ) ; } , deleteProperty ( ) { return false ; } } ) ; proxyMap . set ( proxy , api ) ; return proxy ; }


Input: polyfills the global setImmediate [CODESPLIT] function Ebus ( p ) { "use strict" ; this . debug = false ; this . yields = false ; this . handlers = { } ; if ( p ) { this . priorities = p ; } else { this . priorities = { } ; } }


Input: Common entry point for all API models [CODESPLIT] function ApiClient ( config ) { var self = this this . config = _ . extend ( { } , config , { client : this } ) config . headers = _ . extend ( { } , config . headers , { Accept : 'application/json' } ) this . auth = config . auth models . sync = require ( './sync' ) models . Model = require ( './modelbase' ) models . NginModel = require ( './nginModel' ) // add each model to the ApiClient Object . keys ( models ) . forEach ( function ( modelName ) { Object . defineProperty ( self , modelName , { get : function ( ) { return models [ modelName ] ( self ) } , enumerable : true , configurable : true } ) } ) _ . extend ( this , models ) }


Input: returns - 1 if value being searched for isn t found . value cannot be object . [CODESPLIT] function getFirstIndexOf ( value , array ) { error_if_not_primitive_or_array_1 . errorIfNotPrimitiveOrArray ( value ) ; if ( isArray_notArray_1 . isArray ( value ) ) { return getFirstIndexOfArray_1 . getFirstIndexOfArray ( value , array ) ; } else { // if primitive... return getIndexOfPrimitive_1 . getIndexOfPrimitive ( value , array ) ; } }


Input: / * js / src / isinstance . js [CODESPLIT] function ( type , obj ) { return obj !== null && obj !== undefined && obj . constructor . prototype === type . prototype ; }


Input: breakStringList [CODESPLIT] function breakRoleList ( matcher , list ) { const pieces = [ ] const roleBreaker = XRegExp ( ` \\ ${ matcher . roleMatcher } \\ ` ) for ( let m = list . match ( roleBreaker ) ; m !== null ; m = list . match ( roleBreaker ) ) { const [ consumed , matched ] = m pieces . push ( matched ) list = list . substring ( consumed . length ) } const altFinder = XRegExp ( ` \\ \\ \\ ${ matcher . roleMatcher } ` ) const altMatch = list . match ( altFinder ) if ( altMatch ) { pieces . push ( altMatch [ 2 ] ) } // if ... return pieces }


Input: Scopes the url to the season [CODESPLIT] function scopeUrl ( options , inst ) { options = _ . extend ( { } , inst , options ) if ( ! options . season_id ) throw new Error ( 'season_id required to make division instance api calls' ) return ngin . Season . urlRoot ( ) + '/' + options . season_id + Division . urlRoot ( ) }


Input: main function [CODESPLIT] function process ( ast , scope ) { ast . scope = scope ; ast . names = [ ] ; ast . scopes = [ ] ; var varWalker = function ( token , scope ) { scope . declarations . push ( { type : 'var' , name : token . id . name , parent : this . top ( 1 ) , loc : token . loc . start } ) ; scope . put ( token . id . name , { type : 'var' , token : token . init , loc : token . loc . start } ) ; } ; return walker . walk ( ast , { VariableDeclarator : varWalker , FunctionDeclaration : fnWalker , FunctionExpression : fnWalker , ArrowFunctionExpression : fnWalker , ExpressionStatement : function ( token ) { if ( token . directive && token . directive . toLowerCase ( ) === 'use strict' ) scope . strict = true ; } , CatchClause : function ( token , scope ) { var newScope = new Scope ( 'catch' , scope ) ; scope . put ( token . param . name , { type : 'catch' , token : null } ) ; token . body . scope = newScope ; this . scopes . push ( scope ) ; } , Identifier : function ( token , scope ) { var parent = this . top ( 1 ) ; // let insane begin! // todo implement more efficient solution in a future version var isLabel = parent . type === 'LabeledStatement' || parent . type === 'ContinueStatement' || parent . type === 'BreakStatement' ; var isFunctionName = parent . type === 'FunctionDeclaration' || parent . type === 'FunctionExpression' || parent . type === 'ClassDeclaration' || parent . type === 'ClassExpression' ; var isProperty = parent . type === 'Property' ; var isMemberExpression = parent . type === 'MemberExpression' ; var isAssignmentExpression = parent . type === 'AssignmentExpression' ; var isVariableDeclarator = parent . type === 'VariableDeclarator' ; if ( isLabel || isFunctionName || isProperty || isMemberExpression || isAssignmentExpression || isVariableDeclarator ) { var isObjectKey = isProperty && parent . key === token && parent . computed ; var isObjectValue = isProperty && parent . value === token ; var isMemberExpressionProperty = isMemberExpression && parent . property === token && parent . computed ; var isMemberExpressionObject = isMemberExpression && parent . object === token ; var isVariableInit = isVariableDeclarator && parent . init === token ; var isLeftOfAssignment = isAssignmentExpression && parent . left === token && parent . operator !== '=' ; var isRightOfAssignment = isAssignmentExpression && parent . right === token ; // is it for..in variable? (mark its name as used) var isVarInForIn = false ; if ( isVariableDeclarator ) { var declarationParent = this . top ( 3 ) ; isVarInForIn = declarationParent && declarationParent . type === 'ForInStatement' ; } if ( isFunctionName || isLabel || ! isObjectKey && ! isObjectValue && ! isMemberExpressionProperty && ! isMemberExpressionObject && ! isLeftOfAssignment && ! isRightOfAssignment && ! isVariableInit && ! isVarInForIn ) return ; } this . names . push ( { scope : scope , token : token } ) ; } } , { names : ast . names , scopes : ast . scopes } ) ; }


Input: Scope class [CODESPLIT] function Scope ( type , parentScope , thisObject ) { this . type = type || 'unknown' ; this . thisObject = thisObject || utils . createIdentifier ( 'undefined' ) ; this . subscopes = [ ] ; this . names = { } ; this . declarations = [ ] ; if ( parentScope ) { this . parent = parentScope ; this . root = parentScope . root ; this . strict = parentScope . strict ; parentScope . subscopes . push ( this ) ; } else { this . root = this ; } this . put ( 'this' , { type : 'readonly' , token : this . thisObject } ) ; }


Input: Initialize a new Customer with the given parent and definition . [CODESPLIT] function Customer ( parent , definition ) { var key ; for ( key in updateMixin ) { this [ key ] = updateMixin [ key ] ; } Customer . super_ . apply ( this , arguments ) ; }


Input: This does a shallow copy of objects . This is needed for objects such as Errors Otherwise some properties may not be available . [CODESPLIT] function copy ( obj ) { return Object . getOwnPropertyNames ( obj || { } ) . reduce ( ( a , c ) => { a [ c ] = obj [ c ] ; return a ; } , { } ) ; }


Input: Formats a message using the specified options . [CODESPLIT] function formatWith ( options ) { options = Object . assign ( { } , DEFAULTS , options ) ; return ( message , ... args ) => { return _formatter ( options , message , ... args ) ; } ; }


Input: ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * Prevents errors on console methods when no console present . * Exposes a global debug function that preserves line numbering and formatting . [CODESPLIT] function ( obj ) { var that = { } ; that . obj = obj ; var method ; var con ; if ( typeof window !== 'undefined' ) { window . console = window . console || { } ; con = window . console ; } else { con = console || { } ; } if ( ! con [ 'debug' ] ) { con . debug = con . log ; } // IE does not support debug. var length = methods . length ; while ( length -- ) { method = methods [ length ] ; // Only stub undefined methods. if ( ! con [ method ] ) { // .hasOwnProperty(method) ) { // !con[method] ) { con [ method ] = noop ; // Disable for con that [ method ] = noop ; // and for this object too } else { if ( Function . prototype . bind ) { that [ method ] = Function . prototype . bind . call ( con [ method ] , con , '%s' ) ; // '%s' does not works for group } else { that [ method ] = Function . prototype . apply . call ( con [ method ] , con , 'xyz' , arguments ) ; } } } //if(that.obj) { //  con.log('>>>>>>>>>>>>', that.obj.debugId, that.obj); // } //  if (!con.debug) { // IE does not support con.debug //    that.debug = Function.prototype.bind.call(con.log,   con, pref + ' **** debug:   %s');; //  } else { //    that.debug = Function.prototype.bind.call(con.debug, con, pref + ' **** debug: %s'); //  } /** Rewrite specific methods **/ if ( Function . prototype . bind ) { // con.log('_debug(): if (Function.prototype.bind) '); var pref = '[' + ( ( that . obj && that . obj . debugId ) ? that . obj . debugId : 'null' ) + ']' ; that . error = Function . prototype . bind . call ( con . error , con , pref + ' * error: %s' ) ; that . warn = Function . prototype . bind . call ( con . warn , con , pref + ' ** warn:  %s' ) ; that . info = Function . prototype . bind . call ( con . info , con , pref + ' *** info:  %s' ) ; if ( ! con . debug ) { // IE does not support con.debug that . debug = Function . prototype . bind . call ( con . log , con ) ; //pref + ' **** debug:   %s');; } else { that . debug = Function . prototype . bind . call ( con . debug , con ) ; //pref + ' **** debug: %s'); } that . log = Function . prototype . bind . call ( con . log , con , pref + ' ***** log:   %s' ) ; //    that.group = Function.prototype.bind.call(con.group, con, '%s'); that . group = Function . prototype . bind . call ( con . log , con , pref + ' GROUP:   %s' ) ; //    that.groupCollapsed = Function.prototype.bind.call(con.groupCollapsed, con, '%s'); that . groupCollapsed = Function . prototype . bind . call ( con . log , con , pref + ' GROUP: %s' ) ; //    if (!that.assert) { that.assert = Function.prototype.bind.call(con.error, con, '* assert: %s'); } //  } else { //    that.error = function() { Function.prototype.apply.call(con.error, con, arguments); }; //    that.warn  = function() { Function.prototype.apply.call(con.warn , con, arguments); }; //    that.info  = function() { Function.prototype.apply.call(con.info,  con, arguments); }; //    that.debug = function() { Function.prototype.apply.call(con.debug, con, arguments); }; //    that.log   = function() { Function.prototype.apply.call(con.log,   con, arguments); }; } return that ; }


Input: Zips up a directory . [CODESPLIT] function ( sourceDir , destFile , opts ) { opts = opts || { archive_path : '/' } ; return new Promise ( function ( resolve , reject ) { try { var archive = archiver . create ( 'zip' , { zlib : { level : 9 } } ) ; var output = fs . createWriteStream ( destFile ) ; output . on ( 'finish' , function ( ) { resolve ( destFile ) ; } ) ; archive . pipe ( output ) ; archive . directory ( sourceDir , opts . archive_path ) ; archive . finalize ( ) ; } catch ( err ) { reject ( err ) ; } } ) ; }


Input: Extracts a zip to a directory . This will fail if the destination already exists . [CODESPLIT] function ( sourceFile , destDir ) { return new Promise ( function ( resolve , reject ) { var zip = new AdmZip ( sourceFile ) ; try { zip . extractAllTo ( destDir ) ; resolve ( destDir ) ; } catch ( err ) { reject ( err ) ; } } ) ; }


Input: Create a Bzip2 compressed tar of a directory . [CODESPLIT] function ( sourceDir , destFile , opts ) { opts = opts || { archive_path : '/' } ; return new Promise ( function ( resolve , reject ) { // pack var tempFile = destFile + '.tmp.tar' ; try { var archive = archiver . create ( 'tar' ) ; var output = fs . createWriteStream ( tempFile ) ; output . on ( 'finish' , function ( ) { resolve ( tempFile ) ; } ) ; archive . pipe ( output ) ; archive . directory ( sourceDir , opts . archive_path ) ; archive . finalize ( ) ; } catch ( err ) { reject ( err ) ; } } ) . then ( function ( tempFile ) { // compress try { var data = new Buffer ( fs . readFileSync ( tempFile ) , 'utf8' ) ; var compressed = new Buffer ( Bzip2 . compressFile ( data ) ) ; fs . writeFileSync ( destFile , compressed ) ; return destFile ; } catch ( err ) { throw err ; } finally { rimraf . sync ( tempFile ) ; } } ) ; }


Input: Extracts a tar to a directory . [CODESPLIT] function ( sourceFile , destDir ) { return new Promise ( function ( resolve , reject ) { // expand var tempFile = sourceFile + '.tmp.tar' ; try { var data = new Buffer ( fs . readFileSync ( sourceFile ) ) ; var expanded = Bzip2 . decompressFile ( data ) ; fs . writeFileSync ( tempFile , new Buffer ( expanded ) ) ; resolve ( tempFile ) ; } catch ( err ) { reject ( err ) ; } } ) . then ( function ( tempFile ) { // un-pack return new Promise ( function ( resolve , reject ) { try { var rs = fs . createReadStream ( tempFile ) ; rs . pipe ( tar . extract ( destDir ) . on ( 'finish' , function ( ) { rimraf . sync ( tempFile ) ; resolve ( destDir ) ; } ) ) ; } catch ( err ) { rimraf . sync ( tempFile ) ; reject ( err ) ; } } ) ; } ) ; }


Input: 校验参数 val 是否为负数 [CODESPLIT] function _isNegativeNumber ( val , options ) { var opts = _isObject ( options ) ? options : { } ; if ( opts . isStrict === true ) { return _isNumber ( val ) && REGEX_ENUM . NEGATIVE_NUMBER_REX . test ( val ) ; } return REGEX_ENUM . NEGATIVE_NUMBER_REX . test ( val ) ; }


Input: Recursive promise - based mkdir . [CODESPLIT] async function make ( dir ) { try { await makePromise ( mkdir , dir ) } catch ( err ) { if ( err . code == 'ENOENT' ) { const parentDir = dirname ( dir ) await make ( parentDir ) await make ( dir ) } else if ( err . code != 'EEXIST' ) { // created in parallel throw err } } }


Input: Expose small fabrication helper . [CODESPLIT] function fabricator ( stack , options ) { options = options || { } ; // // Empty strings, arrays or objects should not be processed, return early. // if ( empty ( stack ) ) return [ ] ; switch ( is ( stack ) ) { case 'string' : stack = read ( stack , options ) ; break ; case 'object' : stack = Object . keys ( stack ) . reduce ( iterator ( read , stack , options ) , [ ] ) ; break ; case 'array' : stack = stack . reduce ( iterator ( read , null , options ) , [ ] ) ; break ; default : if ( 'function' !== typeof stack ) { throw new Error ( 'Unsupported type, cannot fabricate an: ' + is ( stack ) ) ; } stack = [ init ( stack , undefined , options ) ] ; } return ( stack || [ ] ) . filter ( Boolean ) ; }


Input: Read directory and initialize JavaScript files . [CODESPLIT] function read ( filepath , options ) { if ( 'string' !== is ( filepath ) ) return fabricator ( filepath , options ) ; if ( options . source ) filepath = path . resolve ( options . source , filepath ) ; // // Check if the provided string is a JS file or when recursion is not allowed. // if ( js ( filepath ) || options . recursive === false ) return [ init ( filepath , path . basename ( filepath , '.js' ) , options ) ] ; // // Read the directory, only process files. // if ( ! fs . existsSync ( filepath ) ) return false ; return fs . readdirSync ( filepath ) . map ( function locate ( file ) { file = path . resolve ( filepath , file ) ; var stat = fs . statSync ( file ) ; if ( stat . isDirectory ( ) && fs . existsSync ( path . join ( file , 'index.js' ) ) ) { // // Use the directory name instead of `index` for name as it probably has // more meaning then just `index` as a name. // return init ( path . join ( file , 'index.js' ) , path . basename ( file , '.js' ) , options ) ; } // // Only allow JS files, init determines if it is a constructible instance. // if ( ! stat . isFile ( ) || ! js ( file ) ) return ; return init ( file , path . basename ( file , '.js' ) , options ) ; } ) ; }


Input: Return iterator for array or object . [CODESPLIT] function iterator ( traverse , obj , options ) { return function reduce ( stack , entity ) { var base = obj ? obj [ entity ] : entity , name = options . name || entity ; // // Fabricated objects should provide each constructor with the name // of its property on the original object. // if ( obj ) options . name = entity ; // // Run the functions, traverse will handle init. // if ( js ( base ) ) { return stack . concat ( init ( base , 'string' === is ( name ) ? name : '' , options ) ) ; } // // When we've been supplied with an array as base assume we want to keep it // as array and do not want it to be merged. // if ( Array . isArray ( base ) ) { options . name = name ; // Force the name of the entry for all items in array. stack . push ( traverse ( base , options ) ) ; return stack ; } return stack . concat ( traverse ( base , options ) ) ; } ; }


Input: Make sure only valid JavaScript files are used as source . Ignore other files like . log files . Also allow constructors . [CODESPLIT] function js ( file ) { var type = is ( file ) ; return 'function' === type || 'string' === type && path . extname ( file ) === '.js' ; }


Input: Simple check to see if the provided stack is empty or falsy . [CODESPLIT] function empty ( value ) { if ( ! value ) return true ; switch ( is ( value ) ) { case "object" : return ! Object . keys ( value ) . length ; case "array" : return ! value . length ; default : return ! value ; } }


Input: It s not required to supply resolve with instances we can just automatically require them if they are using the : [CODESPLIT] function init ( constructor , name , options ) { constructor = ( 'string' === is ( constructor ) ) ? require ( constructor ) : constructor ; // // We really want to have a function/class here. Make sure that we can // construct it using `new constructor` // if ( ! constructor . prototype ) return ; name = constructor . prototype . name || name || constructor . name ; if ( options . name ) name = options . name ; // // Sets the name on the prototype to a string. // if ( 'name' in constructor . prototype ) { constructor . prototype . name = name . toString ( ) ; } return constructor ; }


Input: menu link is a toggle sidebar links are close - only [CODESPLIT] function click ( e ) { var op = 'remove' ; if ( this . className === 'menuLink' ) { op = document . body . classList . contains ( 'menu-open' ) ? 'remove' : 'add' ; e . preventDefault ( ) ; } document . body . classList [ op ] ( 'menu-open' ) ; }


Input: Main function for creating a shellstream [CODESPLIT] function ShellStream ( args ) { if ( this instanceof ShellStream === false ) { return new ShellStream ( args ) ; } this . _command = args ; this . _events = [ ] ; var self = this ; // Create holders for events to be added streams . forEach ( function ( stream ) { self [ stream ] = { on : this . on , _events : [ ] } ; } ) ; }


Input: Read path with options with callback ( err str ) . When options . cache is true the template string will be cached . [CODESPLIT] function read ( path , options , callback ) { var str = readCache [ path ] ; var cached = options . cache && str && ( 'string' === typeof str ) ; // cached (only if cached is a string and not a compiled template function) if ( cached ) { return callback ( null , str ) ; } // read fs . readFile ( path , 'utf8' , function ( err , str ) { if ( err ) { return callback ( err ) ; } // remove extraneous utf8 BOM marker str = str . replace ( / ^\uFEFF / , '' ) ; if ( options . cache ) { readCache [ path ] = str ; } callback ( null , str ) ; } ) ; }


Input: A representation of an object in the profile [CODESPLIT] function ( name , specs ) { this . name = name ; this . id = 0 ; this . properties = specs . properties || [ ] ; this . extends = specs . extends || null ; this . depends = specs . depends || null ; this . factory = specs . factory || "new" ; this . init = specs . init || "default" ; this . frequent = false ; this . keepUsedProperties = false ; this . initProperties = true ; this . initConstructorArgs = [ ] ; this . propCustomAssign = { } ; this . propAssign = "" ; this . propCustomGet = { } ; this . propGet = "" ; this . postInit = specs . postInit || "" ; this . embed = specs . embed || [ ] ; if ( this . postInit ) this . postInit += "\n" ; // Calculate a safe name this . safeName = name . replace ( / [,\.\- \_] / g , '_' ) ; // Change init to 'constructor' if init is array if ( this . init instanceof Array ) { this . initConstructorArgs = this . init ; this . init = "constructor" ; this . factory = "create" } else if ( this . init instanceof { } . constructor ) { this . propCustomAssign = this . init ; this . init = "default" ; // Extract default if ( this . propCustomAssign [ 'default' ] ) { this . propAssign = this . propCustomAssign [ 'default' ] ; delete this . propCustomAssign [ 'default' ] ; } } else if ( this . init !== "default" ) { // Custom user init function if ( this . factory === "new" ) this . factory = "create" ; } // Check if we have custom property getters if ( specs . getter ) { if ( typeof specs == 'object' ) { this . propCustomGet = specs . getter ; // Extract default if ( this . propCustomGet [ 'default' ] ) { this . propGet = this . propCustomGet [ 'default' ] ; delete this . propCustomGet [ 'default' ] ; } } else { this . propGet = specs . getter ; } } // Initialize boolean fields if ( specs . frequent !== undefined ) { this . frequent = ( [ "yes" , "true" , "1" ] . indexOf ( specs . frequent . toString ( ) . toLowerCase ( ) ) >= 0 ) ; } if ( specs . initProperties !== undefined ) { this . initProperties = ( [ "yes" , "true" , "1" ] . indexOf ( specs . initProperties . toString ( ) . toLowerCase ( ) ) >= 0 ) ; } if ( specs . keepUsedProperties !== undefined ) { this . keepUsedProperties = ( [ "yes" , "true" , "1" ] . indexOf ( specs . keepUsedProperties . toString ( ) . toLowerCase ( ) ) >= 0 ) ; } }


Input: Extend our properties based on specified object [CODESPLIT] function ( o ) { // Don't extend 'depends', extend only 'extends' if ( this . extends ) { this . embed = o . embed . concat ( this . embed ) ; this . properties = o . properties . concat ( this . properties ) ; this . postInit = o . postInit + this . postInit ; // Replace init & Factory if different if ( this . init === "default" ) this . init = o . init ; if ( this . factory === "new" ) this . factory = o . factory ; // Replace default property assigned if not defined if ( ! this . propAssign ) this . propAssign = o . propAssign ; // Implement undefined extended property assigners for ( var k in o . propCustomAssign ) { if ( ! this . propCustomAssign [ k ] ) { this . propCustomAssign [ k ] = o . propCustomAssign [ k ] ; } } } }


Input: Generate the property getter [CODESPLIT] function ( instVar , prefix ) { var code = "[" , getCode = "" , prop = "" , defaultGet = "$inst.$prop" ; if ( this . defaultGet ) defaultGet = defaultGet ; for ( var i = 0 , l = this . properties . length ; i < l ; ++ i ) { prop = this . properties [ i ] ; if ( i > 0 ) code += "," ; if ( this . propCustomGet [ prop ] ) { getCode = this . propCustomGet [ prop ] . replace ( / \$inst / g , instVar ) . replace ( / \$prop / g , prop ) ; } else { getCode = defaultGet . replace ( / \$inst / g , instVar ) . replace ( / \$prop / g , prop ) ; } // Check if we should embed this property if ( this . embed . indexOf ( prop ) === - 1 ) { code += "\n" + prefix + getCode ; } else { code += "\n" + prefix + "new BinaryEncoder.FileResource( " + getCode + " )" ; } } code += "]" ; return code ; }


Input: Generate the name of the property initialization function . This is used to de - duplicate init functions for the same properties [CODESPLIT] function ( ) { var props = this . properties . slice ( ) . sort ( ) ; return 'init' + crypto . createHash ( 'md5' ) . update ( props . join ( "," ) ) . digest ( "hex" ) ; }


Input: Generate the piece of code that initializes an instance of the object [CODESPLIT] function ( instVar , valVar , pageszVar , offsetVar , prefix , indent ) { var code = "" , usedProps = { } , defaultAssign = "$inst.$prop = $value" , replaceVariableMacro = ( function ( s , v ) { var i = this . properties . indexOf ( v ) ; if ( i >= 0 ) { usedProps [ v ] = true ; } else { throw "Macro " + s + " refers to a property not part of property table!" ; } } ) . bind ( this ) ; // // [default] - Default empty constructor // if ( this . init == "default" ) { // // [constructor] - Call constructor // } else if ( this . init == 'constructor' ) { code += prefix + this . name + ".call(" + instVar ; for ( var i = 0 , l = this . initConstructorArgs . length ; i < l ; i ++ ) { var arg = this . initConstructorArgs [ i ] , partIdx = arg . search ( / [\.\[] / ) , part = "" , found = false ; // Try to translate constructor arguments to components of the value // array when possivle if ( partIdx == - 1 ) partIdx = arg . length ; part = arg . substr ( 0 , partIdx ) ; for ( var j = 0 , jl = this . properties . length ; j < jl ; ++ j ) { if ( this . properties [ j ] == part ) { arg = valVar + "[" + offsetVar + '+' + pageszVar + '*' + j + "]" + arg . substr ( partIdx ) ; usedProps [ part ] = true ; found = true ; break ; } } // Warn user if not found if ( ! found ) { console . warn ( "Could not find property '" + arg + "' in " + this . name + ". Assuming literal" ) ; } // Update constructor call code += ",\n" + prefix + indent + arg ; } code += ");\n" ; // // [other] - Custom user function // } else { console . warn ( "Using custom init function for " + this . name ) ; code += prefix + this . init + "(" + instVar + ", " + valVar + ");\n" ; } // Replace variable macros in the property assigners & track handled properties for ( var k in this . propCustomAssign ) { this . propCustomAssign [ k ] = this . propCustomAssign [ k ] . replace ( / \$\$(\w+) / g , replaceVariableMacro ) ; } // Get default assign function if ( this . propAssign ) defaultAssign = this . propAssign ; defaultAssign = defaultAssign . replace ( / \$\$(\w+) / g , replaceVariableMacro ) ; // Call property initializer (might be shared with other instances) if ( this . initProperties ) { for ( var i = 0 , l = this . properties . length ; i < l ; ++ i ) { var prop = this . properties [ i ] ; // Skip properties used in the constructor if ( usedProps [ prop ] && ! this . keepUsedProperties ) continue ; if ( this . propCustomAssign [ prop ] ) { code += prefix + this . propCustomAssign [ prop ] . replace ( / \$inst / g , instVar ) . replace ( / \$prop / g , prop ) . replace ( / \$values / g , valVar ) . replace ( / \$value / g , valVar + "[" + offsetVar + '+' + pageszVar + '*' + i + "]" ) + ";\n" ; } else { code += prefix + defaultAssign . replace ( / \$inst / g , instVar ) . replace ( / \$prop / g , prop ) . replace ( / \$values / g , valVar ) . replace ( / \$value / g , valVar + "[" + offsetVar + '+' + pageszVar + '*' + i + "]" ) + ";\n" ; } } } // Call post-init if ( this . postInit ) { code += "\n" + prefix + "// Custom init function\n" ; code += prefix + this . postInit . replace ( / \n / g , "\n" + prefix ) . replace ( / \$inst / g , instVar ) . replace ( / \$values / g , valVar ) . replace ( / \$\$(\w+) / g , replaceVariableMacro ) ; } return code ; }


Input: Read entire buffer and compile [CODESPLIT] function bufferMode ( contents , options , callback ) { ProfileCompiler ( contents . toString ( 'utf-8' ) , options , function ( err , encBuf , decBuf ) { if ( err ) { callback ( err ) ; return ; } // Callback buffers callback ( null , new Buffer ( encBuf , 'utf8' ) , new Buffer ( decBuf , 'utf8' ) ) ; } ) ; }


Input: Read entire stream and process [CODESPLIT] function streamMode ( contents , options , callback ) { toArray ( contents , function ( err , chunks ) { if ( err ) { callback ( err ) ; return ; } bufferMode ( Buffer . concat ( chunks ) , options , function ( err , encBuf , decBuf ) { if ( err ) { callback ( err ) ; return ; } var encStream = new Readable ( ) ; encStream . push ( encBuf ) ; encStream . push ( null ) ; var decStream = new Readable ( ) ; decStream . push ( decBuf ) ; decStream . push ( null ) ; // Callback streams callback ( null , encStream , decStream ) ; } ) ; } ) ; }


Input: Call when finished with compression [CODESPLIT] function ( err , encContents , decContents ) { // Emmit errors if ( err ) { var error = new PluginError ( PLUGIN_NAME , err , { showStack : true } ) ; self . emit ( 'error' , error ) ; done ( ) ; return ; } // Get base name var dir = path . dirname ( originalFile . path ) ; var name = path . basename ( originalFile . path ) ; var parts = name . split ( "." ) ; parts . pop ( ) ; var baseName = self . config . name || parts . join ( "." ) ; // The encode file var f = originalFile . clone ( ) ; f . contents = encContents ; f . path = path . join ( dir , baseName + '-encode.js' ) ; self . push ( f ) ; // The decode file var f = originalFile . clone ( ) ; f . contents = decContents ; f . path = path . join ( dir , baseName + '-decode.js' ) ; self . push ( f ) ; // We are done done ( ) ; return ; }


Input: journal . js [CODESPLIT] function journal ( ) { 'use strict' ; var fs = require ( 'fs' ) ; // private properties var eventList = { 'creationEvents' : { } , 'executionEvents' : { } } ; var logMode ; // sets the log method: 'q', 'v' or 'l' // exposed by the agency constructor function setLogMode ( mode ) { logMode = mode ; } // records the agent's validation and creation events in a temporary structure if log method is 'l' or  // outputs the same events to the console if method is 'v'  function logCreationEvent ( id , type , message , time ) { if ( logMode === 'l' ) { if ( ! eventList . creationEvents [ id ] ) { eventList . creationEvents [ id ] = [ ] ; } eventList . creationEvents [ id ] . push ( { 'type' : type , 'event' : message , "timestamp" : time } ) ; } else if ( logMode === 'v' ) { console . log ( type + ': Agent ' + id + ' ' + message + ' on ' + time ) ; } } // records the agent's execution events in a temporary structure if log method is 'l' or  // outputs the same events to the console if method is 'v'  function logExecutionEvent ( id , type , message , time ) { if ( logMode === 'l' ) { if ( ! eventList . executionEvents [ id ] ) { eventList . executionEvents [ id ] = [ ] ; } eventList . executionEvents [ id ] . push ( { 'type' : type , 'event' : message , "timestamp" : time } ) ; } else if ( logMode === 'v' ) { console . log ( type + ': Agent ' + id + ' ' + message + ' on ' + time ) ; } } // outputs the contents of the temporary creation and execution structure to a specific file // defined by the user; if file is not defined outputs to a default file; otherwise outputs error to the console function report ( logFile ) { var defaultLogFile = ( new Date ( ) ) . toJSON ( ) + '.log' ; var data = JSON . stringify ( eventList , null , 3 ) ; if ( logFile ) { fs . writeFile ( logFile , data , function ( err ) { if ( err ) { console . log ( '\nCould not write log to file "' + logFile + '"\n' + err ) ; fs . writeFile ( defaultLogFile , data , function ( err ) { if ( err ) { console . log ( 'Could not write log file: ' + err ) ; } else { console . log ( 'Log was written on default file "' + defaultLogFile + '"' ) ; } } ) ; } } ) ; } else { fs . writeFile ( defaultLogFile , data , function ( err ) { if ( err ) { console . log ( 'Could not write log file: ' + err ) ; } } ) ; } } //public interface return { setLogMode : setLogMode , logCreationEvent : logCreationEvent , logExecutionEvent : logExecutionEvent , report : report } ; }


Input: records the agent s validation and creation events in a temporary structure if log method is l or outputs the same events to the console if method is v [CODESPLIT] function logCreationEvent ( id , type , message , time ) { if ( logMode === 'l' ) { if ( ! eventList . creationEvents [ id ] ) { eventList . creationEvents [ id ] = [ ] ; } eventList . creationEvents [ id ] . push ( { 'type' : type , 'event' : message , "timestamp" : time } ) ; } else if ( logMode === 'v' ) { console . log ( type + ': Agent ' + id + ' ' + message + ' on ' + time ) ; } }


Input: records the agent s execution events in a temporary structure if log method is l or outputs the same events to the console if method is v [CODESPLIT] function logExecutionEvent ( id , type , message , time ) { if ( logMode === 'l' ) { if ( ! eventList . executionEvents [ id ] ) { eventList . executionEvents [ id ] = [ ] ; } eventList . executionEvents [ id ] . push ( { 'type' : type , 'event' : message , "timestamp" : time } ) ; } else if ( logMode === 'v' ) { console . log ( type + ': Agent ' + id + ' ' + message + ' on ' + time ) ; } }


Input: outputs the contents of the temporary creation and execution structure to a specific file defined by the user ; if file is not defined outputs to a default file ; otherwise outputs error to the console [CODESPLIT] function report ( logFile ) { var defaultLogFile = ( new Date ( ) ) . toJSON ( ) + '.log' ; var data = JSON . stringify ( eventList , null , 3 ) ; if ( logFile ) { fs . writeFile ( logFile , data , function ( err ) { if ( err ) { console . log ( '\nCould not write log to file "' + logFile + '"\n' + err ) ; fs . writeFile ( defaultLogFile , data , function ( err ) { if ( err ) { console . log ( 'Could not write log file: ' + err ) ; } else { console . log ( 'Log was written on default file "' + defaultLogFile + '"' ) ; } } ) ; } } ) ; } else { fs . writeFile ( defaultLogFile , data , function ( err ) { if ( err ) { console . log ( 'Could not write log file: ' + err ) ; } } ) ; } }


Input: Scopes the url to the team and member [CODESPLIT] function scopeUrl ( options , inst ) { options = _ . extend ( { } , inst , options ) if ( ! options . teamcenter_team_id ) throw new Error ( 'teamcenter_team_id required to make TeamCenterContact instance api calls' ) if ( ! options . teamcenter_member_id ) throw new Error ( 'teamcenter_member_id require to make TeamCenterContact instance api calls' ) return ngin . TeamCenterTeam . urlRoot ( ) + '/' + options . teamcenter_team_id + ngin . TeamCenterMember . urlRoot ( ) + '/' + options . teamcenter_member_id + TeamCenterContact . urlRoot ( ) }


Input:
DevToolsApp --------------------------------------------------------------- [CODESPLIT] function installObjectObserve ( ) { var properties = [ "advancedSearchConfig" , "auditsPanelSplitViewState" , "auditsSidebarWidth" , "blockedURLs" , "breakpoints" , "cacheDisabled" , "colorFormat" , "consoleHistory" , "consoleTimestampsEnabled" , "cpuProfilerView" , "cssSourceMapsEnabled" , "currentDockState" , "customColorPalette" , "customDevicePresets" , "customEmulatedDeviceList" , "customFormatters" , "customUserAgent" , "databaseTableViewVisibleColumns" , "dataGrid-cookiesTable" , "dataGrid-DOMStorageItemsView" , "debuggerSidebarHidden" , "disableDataSaverInfobar" , "disablePausedStateOverlay" , "domBreakpoints" , "domWordWrap" , "elementsPanelSplitViewState" , "elementsSidebarWidth" , "emulation.deviceHeight" , "emulation.deviceModeValue" , "emulation.deviceOrientationOverride" , "emulation.deviceScale" , "emulation.deviceScaleFactor" , "emulation.deviceUA" , "emulation.deviceWidth" , "emulation.geolocationOverride" , "emulation.showDeviceMode" , "emulation.showRulers" , "enableAsyncStackTraces" , "eventListenerBreakpoints" , "fileMappingEntries" , "fileSystemMapping" , "FileSystemViewSidebarWidth" , "fileSystemViewSplitViewState" , "filterBar-consoleView" , "filterBar-networkPanel" , "filterBar-promisePane" , "filterBar-timelinePanel" , "frameViewerHideChromeWindow" , "heapSnapshotRetainersViewSize" , "heapSnapshotSplitViewState" , "hideCollectedPromises" , "hideNetworkMessages" , "highlightNodeOnHoverInOverlay" , "highResolutionCpuProfiling" , "inlineVariableValues" , "Inspector.drawerSplitView" , "Inspector.drawerSplitViewState" , "InspectorView.panelOrder" , "InspectorView.screencastSplitView" , "InspectorView.screencastSplitViewState" , "InspectorView.splitView" , "InspectorView.splitViewState" , "javaScriptDisabled" , "jsSourceMapsEnabled" , "lastActivePanel" , "lastDockState" , "lastSelectedSourcesSidebarPaneTab" , "lastSnippetEvaluationIndex" , "layerDetailsSplitView" , "layerDetailsSplitViewState" , "layersPanelSplitViewState" , "layersShowInternalLayers" , "layersSidebarWidth" , "messageLevelFilters" , "messageURLFilters" , "monitoringXHREnabled" , "navigatorGroupByFolder" , "navigatorHidden" , "networkColorCodeResourceTypes" , "networkConditions" , "networkConditionsCustomProfiles" , "networkHideDataURL" , "networkLogColumnsVisibility" , "networkLogLargeRows" , "networkLogShowOverview" , "networkPanelSplitViewState" , "networkRecordFilmStripSetting" , "networkResourceTypeFilters" , "networkShowPrimaryLoadWaterfall" , "networkSidebarWidth" , "openLinkHandler" , "pauseOnCaughtException" , "pauseOnExceptionEnabled" , "preserveConsoleLog" , "prettyPrintInfobarDisabled" , "previouslyViewedFiles" , "profilesPanelSplitViewState" , "profilesSidebarWidth" , "promiseStatusFilters" , "recordAllocationStacks" , "requestHeaderFilterSetting" , "request-info-formData-category-expanded" , "request-info-general-category-expanded" , "request-info-queryString-category-expanded" , "request-info-requestHeaders-category-expanded" , "request-info-requestPayload-category-expanded" , "request-info-responseHeaders-category-expanded" , "resources" , "resourcesLastSelectedItem" , "resourcesPanelSplitViewState" , "resourcesSidebarWidth" , "resourceViewTab" , "savedURLs" , "screencastEnabled" , "scriptsPanelNavigatorSidebarWidth" , "searchInContentScripts" , "selectedAuditCategories" , "selectedColorPalette" , "selectedProfileType" , "shortcutPanelSwitch" , "showAdvancedHeapSnapshotProperties" , "showEventListenersForAncestors" , "showFrameowkrListeners" , "showHeaSnapshotObjectsHiddenProperties" , "showInheritedComputedStyleProperties" , "showMediaQueryInspector" , "showNativeFunctionsInJSProfile" , "showUAShadowDOM" , "showWhitespacesInEditor" , "sidebarPosition" , "skipContentScripts" , "skipStackFramesPattern" , "sourceMapInfobarDisabled" , "sourcesPanelDebuggerSidebarSplitViewState" , "sourcesPanelNavigatorSplitViewState" , "sourcesPanelSplitSidebarRatio" , "sourcesPanelSplitViewState" , "sourcesSidebarWidth" , "standardEmulatedDeviceList" , "StylesPaneSplitRatio" , "stylesPaneSplitViewState" , "textEditorAutocompletion" , "textEditorAutoDetectIndent" , "textEditorBracketMatching" , "textEditorIndent" , "timelineCaptureFilmStrip" , "timelineCaptureLayersAndPictures" , "timelineCaptureMemory" , "timelineCaptureNetwork" , "timeline-details" , "timelineEnableJSSampling" , "timelineOverviewMode" , "timelinePanelDetailsSplitViewState" , "timelinePanelRecorsSplitViewState" , "timelinePanelTimelineStackSplitViewState" , "timelinePerspective" , "timeline-split" , "timelineTreeGroupBy" , "timeline-view" , "timelineViewMode" , "uiTheme" , "watchExpressions" , "WebInspector.Drawer.lastSelectedView" , "WebInspector.Drawer.showOnLoad" , "workspaceExcludedFolders" , "workspaceFolderExcludePattern" , "workspaceInfobarDisabled" , "workspaceMappingInfobarDisabled" , "xhrBreakpoints" ] ; /**
     * @this {!{_storage: Object, _name: string}}
     */ function settingRemove ( ) { this . _storage [ this . _name ] = undefined ; } function objectObserve ( object , observer ) { if ( window [ "WebInspector" ] ) { var settingPrototype = window [ "WebInspector" ] [ "Setting" ] [ "prototype" ] ; if ( typeof settingPrototype [ "remove" ] === "function" ) settingPrototype [ "remove" ] = settingRemove ; } var changedProperties = new Set ( ) ; var scheduled = false ; function scheduleObserver ( ) { if ( ! scheduled ) { scheduled = true ; setImmediate ( callObserver ) ; } } function callObserver ( ) { scheduled = false ; var changes = [ ] ; changedProperties . forEach ( function ( name ) { changes . push ( { name : name } ) ; } ) ; changedProperties . clear ( ) ; observer . call ( null , changes ) ; } var storage = new Map ( ) ; function defineProperty ( property ) { if ( property in object ) { storage . set ( property , object [ property ] ) ; delete object [ property ] ; } Object . defineProperty ( object , property , { get : function ( ) { return storage . get ( property ) ; } , set : function ( value ) { storage . set ( property , value ) ; changedProperties . add ( property ) ; scheduleObserver ( ) ; } } ) ; } for ( var i = 0 ; i < properties . length ; ++ i ) defineProperty ( properties [ i ] ) ; } window . Object . observe = objectObserve ; }


Input: Initialize a new ArticleTranslation with the given parent and definition . [CODESPLIT] function ArticleTranslation ( parent , definition ) { var key ; for ( key in updateMixin ) { this [ key ] = updateMixin [ key ] ; } ArticleTranslation . super_ . apply ( this , arguments ) ; }


Input: === Define the Main Function ================================================= A function for converting lists into human - friendly joined stings e . g . [ A B C ] into A B & C . [CODESPLIT] function ( list , options ) { // short-circuit non-arrays if ( ! Array . isArray ( list ) || Object . prototype . toString . call ( list ) === '[object Arguments]' ) { return String ( list ) ; } // short-circuit empty lists if ( list . length === 0 ) { return '' ; } // make sure we have a sane options object if ( typeof options === 'string' ) { var newOptions = { } ; newOptions [ options ] = true ; options = newOptions ; } if ( typeof options !== 'object' ) { options = { } ; } // set up configuration var def = humanJoin . optionDefaults ; // a local reference to make the code more readable var separator = typeof def . separator === 'string' || typeof def . separator === 'number' ? def . separator : ', ' ; if ( typeof options . separator === 'string' || typeof options . separator === 'number' ) { separator = options . separator ; } separator = '' + separator ; // force to string var conjunction = typeof def . conjunction === 'string' || typeof def . conjunction === 'number' || typeof def . conjunction === 'boolean' ? def . conjunction : ' & ' ; if ( typeof options . conjunction === 'string' || typeof options . conjunction === 'number' || typeof options . conjunction === 'boolean' ) { conjunction = options . conjunction ; } if ( typeof conjunction === 'number' ) { conjunction = '' + conjunction ; // force to string } if ( options . noConjunction ) { conjunction = false ; } var quoteWith = typeof def . quoteWith === 'string' || typeof def . quoteWith === 'number' || typeof def . quoteWith === 'boolean' ? def . quoteWith : false ; if ( typeof options . quoteWith === 'string' || typeof options . quoteWith === 'number' || typeof options . quoteWith === 'boolean' ) { quoteWith = options . quoteWith ; } if ( typeof quoteWith === 'number' ) { quoteWith = '' + quoteWith ; // force to string } var mirrorQuote = typeof def . mirrorQuote === 'boolean' ? def . mirrorQuote : true ; if ( typeof options . mirrorQuote !== 'undefined' ) { mirrorQuote = options . mirrorQuote ? true : false ; } // apply any shortcuts specified if ( options . and ) { conjunction = ' and ' ; } if ( options . or ) { conjunction = ' or ' ; } if ( options . oxford || options . oxfordAnd ) { conjunction = ', and ' ; } if ( options . oxfordOr ) { conjunction = ', or ' ; } // process the array to quote and stringify as needed var stringList = [ ] ; for ( var i = 0 ; i < list . length ; i ++ ) { // for loop rather than forEach to support Arguments objects // force to string stringList [ i ] = '' + list [ i ] ; // quote if needed if ( quoteWith ) { if ( mirrorQuote ) { stringList [ i ] = quoteWith + stringList [ i ] + humanJoin . mirrorString ( quoteWith ) ; } else { stringList [ i ] = quoteWith + stringList [ i ] + quoteWith ; } } } // generate the human-friendly string var ans = stringList . shift ( ) ; while ( stringList . length ) { if ( stringList . length === 1 && conjunction !== false ) { ans += conjunction ; } else { ans += separator ; } ans += stringList . shift ( ) ; } // return the generated string return ans ; }


Input: Blatantly stolen from the fantastic node - obfuscator project by Stephen Mathieson https : // github . com / stephenmathieson / node - obfuscator / blob / master / lib / require . js based on TJ Holowaychuk s commonjs require binding [CODESPLIT] function require ( p , root ) { // third-party module?  use native require if ( '.' != p [ 0 ] && '/' != p [ 0 ] ) { return native_require ( p ) ; } root = root || 'root' ; var path = require . resolve ( p ) ; // if it's a non-registered json file, it // must be at the root of the project if ( ! path && / \.json$ / i . test ( p ) ) { return native_require ( './' + require . basename ( p ) ) ; } var module = require . cache [ path ] ; if ( ! module ) { try { return native_require ( p ) ; } catch ( err ) { throw new Error ( 'failed to require "' + p + '" from ' + root + '\n' + err . message + '\n' + err . stack ) ; } } if ( ! module . exports ) { module . exports = { } ; module . call ( module . exports , module , module . exports , require . relative ( path ) ) ; } return module . exports ; }


Input: Initialize a new MacroAction with the given parent and definition . [CODESPLIT] function MacroAction ( parent , definition ) { var key ; for ( key in updateMixin ) { this [ key ] = updateMixin [ key ] ; } MacroAction . super_ . apply ( this , arguments ) ; }


Input: Converts one JSON object to another using maps specified with from - > to array [CODESPLIT] function map ( obj , source , target , isRecursive = true ) { // Check if parameters have invalid types if ( ( typeof obj ) != "object" ) throw new TypeError ( "The object should be JSON" ) ; if ( ( typeof source ) != "string" && ( typeof source ) != "array" ) throw new TypeError ( "Source should be aither string or array" ) ; if ( ( typeof target ) != "string" && ( typeof target ) != "array" ) throw new TypeError ( "Target should be aither string or array" ) ; // result object init let res = { } ; // get array of properties need to be converted let propS = ( typeof source == "string" ) ? source . replace ( /   / g , '' ) . split ( "," ) : source ; let propT = ( typeof target == "string" ) ? target . replace ( /   / g , '' ) . split ( "," ) : target ; // each property is checked ... for ( let propertyName in obj ) { // ... if need be converted or not let propIndexInSource = propS . indexOf ( propertyName ) ; let newName = ( propIndexInSource != - 1 ) ? propT [ propIndexInSource ] : propertyName ; // take into account that property could be an array if ( isRecursive && obj [ propertyName ] instanceof Array ) { res [ newName ] = [ ] ; for ( var i = 0 ; i < obj [ propertyName ] . length ; i ++ ) { let mappedItem = map ( obj [ propertyName ] [ i ] , source , target , isRecursive ) res [ newName ] . push ( mappedItem ) ; } continue ; } // take into account that JSON object can have nested objects if ( isRecursive && ( ( typeof obj [ propertyName ] ) == "object" ) ) res [ newName ] = map ( obj [ propertyName ] , source , target , isRecursive ) ; else res [ newName ] = obj [ propertyName ] ; } return res ; }


Input: Executes a function as a promise for every item in a list . [CODESPLIT] function ( visit , onFail , opts ) { var fail = onFail ? onFail : utils . ret ( false ) , config = opts || { compact : true } ; return function ( list ) { var p = Promise . resolve ( false ) , results = [ ] ; list . forEach ( function ( l , i ) { p = p . then ( visit . bind ( null , l ) ) . catch ( function ( err ) { return fail ( err , l ) ; } ) . then ( function ( result ) { results . push ( result ) ; if ( config . onProgress ) config . onProgress ( list . length , i + 1 , l ) ; } ) ; } ) ; return p . then ( function ( ) { return config . compact ? results . filter ( Boolean ) : results ; } ) ; } ; }


Input:
Turns a standard callback method into a promise - style method . Assumes standard node . js style : someFunction ( arg1 arg2 function ( err data ) { ... } ) [CODESPLIT] function ( module , fn ) { var hasModule = typeof module !== 'function' , f = hasModule ? module [ fn ] : module , mod = hasModule ? module : null ; return function ( ) { var args = [ ] , i = arguments . length - 1 ; /**
             *  Don't pass an arguments list that has undefined values at the end.
             *      This is so the callback for function gets passed in the right slot.
             *
             *      If the function gets passed:
             *          f(arg1, arg2, undefined, cb)
             *
             *      ...it will think it got an undefined cb.
             *
             *      We instead want it to get passed:
             *          f(arg1, arg2, cb)
             *
             *      Before:    [arg1, null, undefined, arg2, undefined, undefined]
             *      After:     [arg1, null, undefined, arg2]
             */ while ( i >= 0 && typeof arguments [ i ] === 'undefined' ) { -- i ; } while ( i >= 0 ) { args . unshift ( arguments [ i ] ) ; -- i ; } return new Promise ( function ( resolve , reject ) { try { resolve ( f . apply ( mod , args ) ) ; } catch ( err ) { reject ( err ) ; } } ) ; } ; }


Input:
Calls promisify on all valid functions on a module . Ignores certain properties on a modules so the return values is not polluted . ( This can be configured by passing in a filter function via opts . isValid . ) [CODESPLIT] function ( module , opts ) { var config = opts || { } , isValid = config . isValid || function ( f , fn , mod ) { /**
                     * Filter out functions that aren't 'public' and aren't 'methods' and aren't asynchronous.
                     *  This is mostly educated guess work based on de facto naming standards for js.
                     *
                     * e.g.
                     *      valid:        'someFunctionName' or 'some_function_name' or 'someFunctionAsync'
                     *      not valid:    'SomeConstructor' or '_someFunctionName' or 'someFunctionSync'
                     *
                     *  As there may be exceptions to these rules for certain modules,
                     *   you can pass in a function via opts.isValid which will override this.
                     */ return typeof f === 'function' && fn [ 0 ] !== '_' && fn [ 0 ] . toUpperCase ( ) !== fn [ 0 ] && ! fn . endsWith ( 'Sync' ) ; } ; return utils . mapObject ( module , function ( f , fn , mod ) { return utils . promisify ( mod , fn ) ; } , isValid ) ; }


Input: Attaches resource data to a given object . The resource data is usually used to store metadata ( e . g . a content type ) for an object . [CODESPLIT] function resource ( object , data ) { if ( data === undefined ) return resourceMap . get ( object ) || { } ; if ( ! object || typeof object !== "object" && typeof object !== "function" || resourceMap . has ( object ) ) throw new TypeError ( "Could not transform given object into a resource." ) ; if ( ! data || typeof data !== "object" ) throw new TypeError ( "Resource data has to be an object." ) ; resourceMap . set ( object , data ) ; return object ; }


Input: Scopes the url to the tournament or flight [CODESPLIT] function scopeUrl ( options , inst ) { options = _ . extend ( _ . clone ( options || { } ) , inst ) if ( typeof options !== 'object' && ! options . flight_id ) throw new Error ( 'flight_id required to make flight defaults api calls' ) return ngin . Flight . urlRoot ( ) + '/' + options . flight_id + FlightStage . urlRoot ( ) }


Input: Old snake_case method [CODESPLIT] function ( ) { console . warn ( 'Code is using deprecated teams_advancing, switch to teamsAdvancing' ) var where = ( new Error ( ) . stack || '' ) . split ( '\n' , 3 ) [ 2 ] if ( where ) console . warn ( where ) this . teamsAdvancing . apply ( this , arguments ) }


Input: According to tests this error - checking does not slow down execution . It s not necessary to worry about repetitive error - checking slowing down execution when this function is called inside a loop . [CODESPLIT] function getIndexOfPrimitive ( primitive , array , startingPosition ) { if ( startingPosition === void 0 ) { startingPosition = 0 ; } errorIfNotPrimitive_1 . errorIfNotPrimitive ( primitive ) ; error_if_not_populated_array_1 . errorIfNotPopulatedArray ( array ) ; errorIfNotInteger_1 . errorIfNotInteger ( startingPosition ) ; return array . indexOf ( primitive , startingPosition ) ; }


Input:
Attach various of event listeners to a given XHR request . [CODESPLIT] function loads ( xhr , ee ) { var onreadystatechange , onprogress , ontimeout , onabort , onerror , onload , timer ; /**
   * Error listener.
   *
   * @param {Event} evt Triggered error event.
   * @api private
   */ onerror = xhr . onerror = one ( function onerror ( evt ) { var status = statuscode ( xhr ) , err = fail ( new Error ( 'Network request failed' ) , status ) ; ee . emit ( 'error' , err ) ; ee . emit ( 'end' , err , status ) ; } ) ; /**
   * Fix for FireFox's odd abort handling behaviour. When you press ESC on an
   * active request it triggers `error` instead of abort. The same is called
   * when an HTTP request is canceled onunload.
   *
   * @see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
   * @see https://bugzilla.mozilla.org/show_bug.cgi?id=880200
   * @see https://code.google.com/p/chromium/issues/detail?id=153570
   * @param {Event} evt Triggerd abort event
   * @api private
   */ onabort = xhr . onabort = function onabort ( evt ) { onerror ( evt ) ; } ; /**
   * ReadyStateChange listener.
   *
   * @param {Event} evt Triggered readyState change event.
   * @api private
   */ onreadystatechange = xhr . onreadystatechange = function change ( evt ) { var target = evt . target ; if ( 4 === target . readyState ) return onload ( evt ) ; } ; /**
   * The connection has timed out.
   *
   * @api private
   */ ontimeout = xhr . ontimeout = one ( function timeout ( evt ) { ee . emit ( 'timeout' , evt ) ; // // Make sure that the request is aborted when there is a timeout. If this // doesn't trigger an error, the next call will. // if ( xhr . abort ) xhr . abort ( ) ; onerror ( evt ) ; } ) ; // // Fallback for implementations that did not ship with timer support yet. // Microsoft's XDomainRequest was one of the first to ship with `.timeout` // support so we all XHR implementations before that require a polyfill. // // @see https://bugzilla.mozilla.org/show_bug.cgi?id=525816 // if ( xhr . timeout ) timer = setTimeout ( ontimeout , + xhr . timeout ) ; /**
   * IE needs have it's `onprogress` function assigned to a unique function. So,
   * no touchy touchy here!
   *
   * @param {Event} evt Triggered progress event.
   * @api private
   */ onprogress = xhr . onprogress = function progress ( evt ) { var status = statuscode ( xhr ) , data ; ee . emit ( 'progress' , evt , status ) ; if ( xhr . readyState >= 3 && status . code === 200 && ( data = response ( xhr ) ) ) { ee . emit ( 'stream' , data , status ) ; } } ; /**
   * Handle load events an potential data events for when there was no streaming
   * data.
   *
   * @param {Event} evt Triggered load event.
   * @api private
   */ onload = xhr . onload = one ( function load ( evt ) { var status = statuscode ( xhr ) , data = response ( xhr ) ; if ( status . code < 100 || status . code > 599 ) return onerror ( evt ) ; // // There is a bug in FireFox's XHR2 implementation where status code 204 // triggers a "no element found" error and bad data. So to be save here, // we're just **never** going to emit a `stream` event as for 204's there // shouldn't be any content. // // @see https://bugzilla.mozilla.org/show_bug.cgi?id=521301 // if ( data && status . code !== 204 ) { ee . emit ( 'stream' , data , status ) ; } ee . emit ( 'end' , undefined , status ) ; } ) ; // // Properly clean up the previously assigned event listeners and timers to // prevent potential data leaks and unwanted `stream` events. // ee . once ( 'end' , function cleanup ( ) { xhr . onreadystatechange = onreadystatechange = xhr . onprogress = onprogress = xhr . ontimeout = ontimeout = xhr . onerror = onerror = xhr . onabort = onabort = xhr . onload = onload = nope ; if ( timer ) clearTimeout ( timer ) ; } ) ; return xhr ; }


Input: SASS plugin for Sheetify ( str str obj fn ) - > null [CODESPLIT] function sheetifyNest ( filename , source , opts , done ) { var processor = postcss ( [ nest ( opts ) ] ) processor . process ( source ) . then ( function ( res ) { done ( null , res . css ) } ) . catch ( done ) }


Input: / * var cache = require ( cachewatch ) ; var watch = cache () ; watch . setToken ( -- My key -- ) ; [CODESPLIT] function Cache ( key , opt ) { if ( ! ( this instanceof Cache ) ) return new Cache ( key , opt ) ; if ( key ) this . setToken ( key ) ; this . config = _ . defaults ( opt || { } , { protocol : 'https' , fragment : '_escaped_fragment_' , service : 'service.cache.watch' , path : '/' , sender : { method : 'get' , headers : { 'User-Agent' : 'CacheWatch Client' } , } , auth : 'x-cache-watch' , lengths : 150 , useragent : pack . config . useragent , url : pack . config . extencion } ) ; var that = this ; that . watch = function CacheWatch ( req , res , next ) { var query = querystring . parse ( url . parse ( req . url ) . query ) ; if ( that . isNot ( req , query ) || ! that . key ) return next ( ) ; that . get ( that . createUrl ( req , query ) , function ( err , resp , body ) { if ( err || that . res ( resp ) ) return next ( ) ; res . setHeader ( 'CacheWatch' , Cache . version ) ; res . setHeader ( 'last-modified' , resp . headers [ 'last-modified' ] ) ; res . setHeader ( 'content-type' , resp . headers [ 'content-type' ] ) ; res . send ( body ) ; } ) ; } ; }


Input: Add a filename to the list with its dependencies first [CODESPLIT] function addWithDependencies ( allFiles , newFile , dependencies , currentFiles , cycleCheck ) { if ( cycleCheck . indexOf ( newFile ) >= 0 ) { throw new Error ( 'Dependency cycle found ' + JSON . stringify ( cycleCheck ) ) } cycleCheck . push ( newFile ) try { // Add dependencies first if ( dependencies [ newFile ] ) { dependencies [ newFile ] . forEach ( function ( dependency ) { if ( allFiles . indexOf ( dependency ) < 0 ) { throw new Error ( 'Dependency "' + dependency + '" of file "' + newFile + '" is not part of ' + JSON . stringify ( allFiles ) ) } addWithDependencies ( allFiles , dependency , dependencies , currentFiles , cycleCheck ) } ) } if ( currentFiles . indexOf ( newFile ) < 0 ) { currentFiles . push ( newFile ) } } finally { cycleCheck . pop ( ) } return currentFiles }


Input: Order files by their dependencies ( insert dependencies first ) [CODESPLIT] function orderFiles ( allFiles , dependencies ) { var result = [ ] allFiles . forEach ( function ( newFile ) { addWithDependencies ( allFiles , newFile , dependencies , result , [ ] ) } ) return result }


Input: Given a new LevelUp chain - style batch a denormalized Common Form and the output of commonform - merkleize for that Common Form add LevelUp put operations to the batch for the Common Form and each of its children . [CODESPLIT] function batchForms ( batch , form , merkle ) { // Use commonform-stringify to produce the text to be stored. var stringified = stringify ( form ) var digest = merkle . digest batch . put ( digest , stringified ) // Recurse children. form . content . forEach ( function ( element , index ) { if ( isChild ( element ) ) { var childForm = element . form var childMerkle = merkle . content [ index ] batchForms ( batch , childForm , childMerkle ) } } ) }


Input: JSON . parse wrapped to take an errback . [CODESPLIT] function parseJSON ( input , callback ) { var error var result try { result = JSON . parse ( input ) } catch ( e ) { error = e } callback ( error , result ) }


Input: / * Utils . create . folder () ; Utils . create . file () ; Create folder if needed Then create file [CODESPLIT] function createFile ( filePath , fileContent ) { var folderPath = filePath . split ( '/' ) ; folderPath . pop ( ) ; folderPath = folderPath . join ( '/' ) ; if ( ! Utils . exist ( folderPath ) ) createFolder ( folderPath ) ; fs . writeFileSync ( filePath , fileContent ) ; Utils . log ( 'Created file: ' + filePath ) ; return Utils ; }


Input: Builds the url based on crazy [CODESPLIT] function scopeUrl ( options , inst ) { options = _ . extend ( _ . clone ( options || { } ) , inst ) var route = [ ] if ( options . season_id ) route . push ( 'seasons' , options . season_id ) if ( options . flight_stage_id ) route . push ( 'flight_stages' , options . flight_stage_id ) else if ( options . division_id ) route . push ( 'divisions' , options . division_id ) else if ( options . pool_id ) route . push ( 'pools' , options . pool_id ) route . push ( 'standings' ) var base = config . urls && config . urls . sports || config . url return Url . resolve ( base , route . join ( '/' ) ) }


Input: Format number [CODESPLIT] function formatNum ( value , type ) { const conv = { scientific : ".3e" , si : ".3s" , rounded : ".3r" } ; if ( type === 'raw' ) return value ; if ( value === undefined || value === null || Number . isNaN ( value ) ) return '' ; return value == parseFloat ( value ) ? d3 . format ( conv [ type ] ) ( value ) : value ; }


Input: Extend WebSocket to automatically reconnect [CODESPLIT] function ReconnectingWebSocket ( url , opts ) { if ( ! ( this instanceof ReconnectingWebSocket ) ) { throw new TypeError ( 'Cannot call a constructor as a function' ) ; } opts = opts || { } ; var self = this ; function getOpt ( name , def ) { return opts . hasOwnProperty ( name ) ? opts [ name ] : def ; } var timeout = getOpt ( 'timeout' , 100 ) ; var maxRetries = getOpt ( 'maxRetries' , 5 ) ; var curRetries = 0 ; // External event callbacks self . onmessage = noop ; self . onopen = noop ; self . onclose = noop ; function unreliableOnOpen ( e ) { self . onopen ( e ) ; curRetries = 0 ; } function unreliableOnClose ( e ) { self . onclose ( e ) ; if ( curRetries < maxRetries ) { ++ curRetries ; setTimeout ( connect , timeout ) ; } } function unreliableOnMessage ( e ) { self . onmessage ( e ) ; } function connect ( ) { // Constructing a WebSocket() with opts.protocols === undefined // does NOT behave the same as calling it with only one argument // (specifically, it throws security errors). if ( opts . protocols ) { self . ws = new WebSocket ( url , opts . protocols ) ; } else { self . ws = new WebSocket ( url ) ; } // onerror isn't necessary: it is always accompanied by onclose self . ws . onopen = unreliableOnOpen ; self . ws . onclose = unreliableOnClose ; self . ws . onmessage = unreliableOnMessage ; } connect ( ) ; this . connect = connect ; }


Input: returns - 1 if array being searched for isn t found . if arrayToSearchFor contains objects this will always return - 1 . [CODESPLIT] function getFirstIndexOfArray ( arrayToSearchFor , arrayToSearchInside ) { errorIfNotArray_1 . errorIfNotArray ( arrayToSearchFor ) ; error_if_not_populated_array_1 . errorIfNotPopulatedArray ( arrayToSearchInside ) ; return arrayToSearchInside . findIndex ( function ( value ) { return ( isArray_notArray_1 . isArray ( value ) && arrays_match_1 . arraysMatch ( value , arrayToSearchFor ) ) ; } ) ; }


Input: 校验参数 val 是否为 正整数 [CODESPLIT] function _isPositiveInteger ( val , options ) { var opts = _isObject ( options ) ? options : { } ; if ( opts . isStrict === true ) { return _isNumber ( val ) && REGEX_ENUM . POSITIVE_INTEGER_REX . test ( val ) ; } return REGEX_ENUM . POSITIVE_INTEGER_REX . test ( val ) ; }


Input: Creates a { [CODESPLIT] function client ( protocol ) { if ( ! protocol || typeof protocol !== "object" ) throw new TypeError ( "owe ClientApi protocols have to be objects." ) ; if ( typeof protocol . closer !== "function" ) throw new TypeError ( "owe ClientApi proctols have to offer a closer function." ) ; if ( protocol . init && typeof protocol . init !== "function" ) throw new TypeError ( "owe ClientApi protocols have to offer an init function." ) ; let connected = false ; const observers = new Set ( ) ; protocol = Object . assign ( { get connected ( ) { return connected ; } , set connected ( value ) { if ( typeof value !== "boolean" ) throw new TypeError ( "Protocol connection state has to be boolean." ) ; if ( value === connected ) return ; connected = value ; for ( const observer of observers ) observer ( connected ) ; } , observe ( observer ) { if ( typeof observer !== "function" ) throw new TypeError ( "Protocol connection state observers have to be functions." ) ; observers . add ( observer ) ; } , unobserve ( observer ) { observers . delete ( observer ) ; } } , protocol ) ; if ( protocol . init ) protocol . init ( ) ; return new ClientApi ( protocol ) ; }


Input: Recursively creates a file [CODESPLIT] function writePath ( parentDir , path , data ) { let files = path . split ( '/' ) ; let file = files . shift ( ) ; // init file if ( ! parentDir [ file ] ) parentDir [ file ] = { content : undefined , tree : { } } ; if ( files . length > 0 ) { writePath ( parentDir [ file ] . tree , files . join ( '/' ) , data ) ; } else if ( data ) { parentDir [ file ] . content = data . toString ( ) ; } }


Input: Is set by the task _read_overrides_and_resolutions [CODESPLIT] function ( mainFiles /*, component*/ ) { for ( var i = 0 ; i < mainFiles . length ; i ++ ) { //Use no-minified version if available var parts = mainFiles [ i ] . split ( '.' ) , ext = parts . pop ( ) , min = parts . pop ( ) , fName ; if ( min == 'min' ) { parts . push ( ext ) ; fName = parts . join ( '.' ) ; if ( grunt . file . exists ( fName ) ) mainFiles [ i ] = fName ; } } return mainFiles ; }


Input: class RoleFinder [CODESPLIT] function descendantRoles ( roles , fieldName , allDescendants ) { return roles . map ( role => allDescendants . get ( role ) ) . filter ( descendants => ! ! descendants ) . map ( descendants => descendants . get ( fieldName ) ) . filter ( fieldRoles => ! ! fieldRoles ) }


Input: descendantRoles [CODESPLIT] function mapOfMaps ( ) { const m = new Map ( ) m . getOrCreate = function ( key ) { if ( ! this . has ( key ) ) this . set ( key , mapOfMaps ( ) ) return this . get ( key ) } return m }


Input: mapOfMaps [CODESPLIT] function mapOfArrays ( ) { const m = new Map ( ) m . getOrCreate = function ( key ) { if ( ! this . has ( key ) ) this . set ( key , [ ] ) return this . get ( key ) } return m }


Input: The profile index where profile objects are contained . [CODESPLIT] function ( ) { this . objects = { } ; this . index = [ ] ; this . _objTree = [ ] ; this . _objList = [ ] ; this . _properties = { } ; this . _propID = 0 ; this . _decodeIndex = [ ] ; this . _objFreq = [ ] ; this . _objInfeq = [ ] ; this . shortNames = true ; this . indent = "\t" ; this . hasEmbed = false ; }


Input: Add a profile object on the index [CODESPLIT] function ( po ) { this . objects [ po . name ] = po ; if ( po . extends ) { this . _objTree . push ( [ po . extends , po . name ] ) ; } else if ( po . depends ) { this . _objTree . push ( [ po . depends , po . name ] ) ; } else { this . _objList . push ( po . name ) ; } }


Input: Generates a divide - and - conquer nested if - statements up to maximum depth steps deep . After that it performs equality testing using a switch - case statement . [CODESPLIT] function ( index_offset , size , depth , prefix , testVar , callback ) { if ( size == 0 ) return prefix + this . indent + "/* No items */\n" ; var code = "" ; genChunk = ( function ( s , e , d , pf ) { if ( d === 0 ) { code += pf + "switch (" + testVar + ") {\n" ; for ( var i = s ; i < e ; ++ i ) { code += pf + this . indent + "case " + ( index_offset + i ) + ": return " + callback ( i ) ; } code += pf + "}\n" ; } else { // No items if ( e == s ) { // Only 1 item } else if ( e == s + 1 ) { code += pf + "if (" + testVar + " === " + ( index_offset + s ) + ")\n" ; code += pf + this . indent + "return " + callback ( s ) ; } else { var mid = Math . round ( ( s + e ) / 2 ) ; code += pf + "if (" + testVar + " < " + ( index_offset + mid ) + ") {\n" ; genChunk ( s , mid , d - 1 , pf + this . indent ) ; code += pf + "} else {\n" ; genChunk ( mid , e , d - 1 , pf + this . indent ) ; code += pf + "}\n" ; } } } ) . bind ( this ) ; genChunk ( 0 , size , depth , prefix + this . indent ) ; return code ; }


Input: Return the property variable name used to optimize for size the minified result . [CODESPLIT] function ( name ) { var id = this . _properties [ name ] ; if ( id === undefined ) { if ( this . shortNames ) { id = this . _properties [ name ] = 'p' + ( this . _propID ++ ) . toString ( ) } else { id = this . _properties [ name ] = 'p' + name [ 0 ] . toUpperCase ( ) + name . substr ( 1 ) . toLowerCase ( ) . replace ( / [,\.\- \_] / g , '_' ) } } }


Input: Resolve dependencies and arrange objects accoridng to priority and priority . [CODESPLIT] function ( ) { // Reset index this . index = [ ] ; // Apply extends to the objects for ( var i = 0 , l = this . _objTree . length ; i < l ; ++ i ) { if ( this . objects [ this . _objTree [ i ] [ 0 ] ] === undefined ) { throw "Extending unknown object " + this . _objTree [ i ] [ 0 ] ; } // Apply this . objects [ this . _objTree [ i ] [ 1 ] ] . applyExtend ( this . objects [ this . _objTree [ i ] [ 0 ] ] ) ; } // Resolve dependencies var deps = toposort ( this . _objTree ) . reverse ( ) , used = { } ; for ( var i = 0 , l = deps . length ; i < l ; ++ i ) { used [ deps [ i ] ] = 1 ; this . objects [ deps [ i ] ] . id = this . index . length ; this . index . push ( this . objects [ deps [ i ] ] ) ; } // Then include objects not part of dependency tree for ( var i = 0 , l = this . _objList . length ; i < l ; ++ i ) { // Skip objects already used in the dependency resolution if ( ! used [ this . _objList [ i ] ] ) { this . index . push ( this . objects [ this . _objList [ i ] ] ) ; } } // Then pre-cache property IDs for all the propeties // and check if any of the objects has embeds for ( var i = 0 , l = this . index . length ; i < l ; ++ i ) { var pp = this . index [ i ] . properties ; for ( var j = 0 , jl = pp . length ; j < jl ; ++ j ) { this . propertyVar ( pp [ j ] ) ; } if ( this . index [ i ] . embed . length > 0 ) { this . hasEmbed = true ; } } // Separate to frequent and infrequent objects for ( var i = 0 , l = this . index . length ; i < l ; ++ i ) { var obj = this . index [ i ] , isFreq = obj . frequent ; // Make sure we only register 5-bit objects if ( isFreq ) { if ( this . _objFreq . length >= MAX_FREQ_ITEMS ) { isFreq = false ; } } // Put on frequent or infrequent table if ( isFreq ) { obj . id = this . _objFreq . length ; this . _objFreq . push ( obj ) ; } else { obj . id = this . _objInfeq . length + MAX_FREQ_ITEMS ; this . _objInfeq . push ( obj ) ; } } }


Input: Generate a table with all the property constants [CODESPLIT] function ( ) { var pn = Object . keys ( this . _properties ) ; var code = "var " ; for ( var i = 0 , l = pn . length ; i < l ; ++ i ) { if ( i !== 0 ) code += ",\n" ; code += this . indent + this . _properties [ pn [ i ] ] + " = '" + pn [ i ] + "'" ; } code += ";\n" ; return code ; }


Input: Generate the list of init functions used by the lookup fcatory to generate the items [CODESPLIT] function ( ) { var code = "" ; // Collect object initializers for ( var i = 0 , l = this . index . length ; i < l ; ++ i ) { var o = this . index [ i ] ; code += "/**\n * Factory & Initializer of " + o . name + "\n */\n" ; code += "var factory_" + o . safeName + " = {\n" ; code += this . indent + "props: " + o . properties . length + ",\n" ; code += this . indent + "create: function() {\n" ; code += this . indent + this . indent + "return " + o . generateFactory ( ) + ";\n" ; code += this . indent + "},\n" ; code += this . indent + "init: function(inst, props, pagesize, offset) {\n" ; code += o . generateInitializer ( 'inst' , 'props' , 'pagesize' , 'offset' , this . indent + this . indent , this . indent ) ; code += this . indent + "}\n" ; code += "}\n\n" ; } return code ; }


Input: Generate the lookup factory by ID [CODESPLIT] function ( prefix ) { var code = "function( id ) {\n" ; code += prefix + this . indent + "if (id < " + MAX_FREQ_ITEMS + ") {\n" ; code += this . generateDnCif ( 0 , this . _objFreq . length , 3 , prefix + this . indent , 'id' , ( function ( i ) { return "factory_" + this . _objFreq [ i ] . safeName + ";\n" } ) . bind ( this ) ) ; code += prefix + this . indent + "} else {\n" ; code += this . generateDnCif ( MAX_FREQ_ITEMS , this . _objInfeq . length , 3 , prefix + this . indent , 'id' , ( function ( i ) { return "factory_" + this . _objInfeq [ i ] . safeName + ";\n" } ) . bind ( this ) ) ; code += prefix + this . indent + "}\n" ; code += prefix + "}\n" ; return code ; }


Input: Generate the function to use for identifying an object [CODESPLIT] function ( prefix ) { var code = "function( inst ) {\n" ; for ( var i = 0 , l = this . index . length ; i < l ; ++ i ) { var o = this . index [ i ] ; if ( i === 0 ) code += prefix + this . indent + "if" ; else code += prefix + this . indent + "} else if" ; code += " (inst instanceof " + o . name + ") {\n" ; code += prefix + this . indent + this . indent + "return [" + o . id + ", getter_" + o . safeName + "];\n" ; } code += prefix + this . indent + "}\n" ; code += prefix + "}\n" return code ; }


Input: Generate the function that is used to encode an object [CODESPLIT] function ( ) { var code = "" ; // Collect object initializers for ( var i = 0 , l = this . index . length ; i < l ; ++ i ) { var o = this . index [ i ] ; code += "/**\n * Property getter " + o . name + "\n */\n" ; code += "function getter_" + o . safeName + "(inst) {\n" ; code += this . indent + "return " + o . generatePropertyGetter ( 'inst' , this . indent + this . indent ) + ";\n" ; code += "}\n\n" ; } code += "\n" return code ; }