Input: / * ▄████▄ ▄████▄ ▄████▄ ██ ██ ██████ ██ ▀▀ ██▄▄██ ██ ▀▀ ██▄▄██ ██▄▄ ██ ▄▄ ██▀▀██ ██ ▄▄ ██▀▀██ ██▀▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██████ [CODESPLIT] function ( c , callback , $tbodies ) { var cache , val , txt , rowIndex , colIndex , tbodyIndex , $tbody , $row , cols , $cells , cell , cacheTime , totalRows , rowData , prevRowData , colMax , span , cacheIndex , hasParser , max , len , index , table = c . table , parsers = c . parsers ; // update tbody variable c . $tbodies = c . $table . children ( 'tbody:not(.' + c . cssInfoBlock + ')' ) ; $tbody = typeof $tbodies === 'undefined' ? c . $tbodies : $tbodies , c . cache = { } ; c . totalRows = 0 ; // if no parsers found, return - it's an empty table. if ( ! parsers ) { return c . debug ? console . warn ( 'Warning: *Empty table!* Not building a cache' ) : '' ; } if ( c . debug ) { cacheTime = new Date ( ) ; } // processing icon if ( c . showProcessing ) { ts . isProcessing ( table , true ) ; } for ( tbodyIndex = 0 ; tbodyIndex < $tbody . length ; tbodyIndex ++ ) { colMax = [ ] ; // column max value per tbody cache = c . cache [ tbodyIndex ] = { normalized : [ ] // array of normalized row data; last entry contains 'rowData' above // colMax: #   // added at the end } ; totalRows = ( $tbody [ tbodyIndex ] && $tbody [ tbodyIndex ] . rows . length ) || 0 ; for ( rowIndex = 0 ; rowIndex < totalRows ; ++ rowIndex ) { rowData = { // order: original row order # // $row : jQuery Object[] child : [ ] , // child row text (filter widget) raw : [ ] // original row text } ; /** Add the table data to main data array */ $row = $ ( $tbody [ tbodyIndex ] . rows [ rowIndex ] ) ; cols = [ ] ; // if this is a child row, add it to the last row's children and continue to the next row // ignore child row class, if it is the first row if ( $row . hasClass ( c . cssChildRow ) && rowIndex !== 0 ) { len = cache . normalized . length - 1 ; prevRowData = cache . normalized [ len ] [ c . columns ] ; prevRowData . $row = prevRowData . $row . add ( $row ) ; // add 'hasChild' class name to parent row if ( ! $row . prev ( ) . hasClass ( c . cssChildRow ) ) { $row . prev ( ) . addClass ( ts . css . cssHasChild ) ; } // save child row content (un-parsed!) $cells = $row . children ( 'th, td' ) ; len = prevRowData . child . length ; prevRowData . child [ len ] = [ ] ; // child row content does not account for colspans/rowspans; so indexing may be off cacheIndex = 0 ; max = c . columns ; for ( colIndex = 0 ; colIndex < max ; colIndex ++ ) { cell = $cells [ colIndex ] ; if ( cell ) { prevRowData . child [ len ] [ colIndex ] = ts . getParsedText ( c , cell , colIndex ) ; span = $cells [ colIndex ] . colSpan - 1 ; if ( span > 0 ) { cacheIndex += span ; max += span ; } } cacheIndex ++ ; } // go to the next for loop continue ; } rowData . $row = $row ; rowData . order = rowIndex ; // add original row position to rowCache cacheIndex = 0 ; max = c . columns ; for ( colIndex = 0 ; colIndex < max ; ++ colIndex ) { cell = $row [ 0 ] . cells [ colIndex ] ; if ( cell && cacheIndex < c . columns ) { hasParser = typeof parsers [ cacheIndex ] !== 'undefined' ; if ( ! hasParser && c . debug ) { console . warn ( 'No parser found for row: ' + rowIndex + ', column: ' + colIndex + '; cell containing: "' + $ ( cell ) . text ( ) + '"; does it have a header?' ) ; } val = ts . getElementText ( c , cell , cacheIndex ) ; rowData . raw [ cacheIndex ] = val ; // save original row text // save raw column text even if there is no parser set txt = ts . getParsedText ( c , cell , cacheIndex , val ) ; cols [ cacheIndex ] = txt ; if ( hasParser && ( parsers [ cacheIndex ] . type || '' ) . toLowerCase ( ) === 'numeric' ) { // determine column max value (ignore sign) colMax [ cacheIndex ] = Math . max ( Math . abs ( txt ) || 0 , colMax [ cacheIndex ] || 0 ) ; } // allow colSpan in tbody span = cell . colSpan - 1 ; if ( span > 0 ) { index = 0 ; while ( index <= span ) { // duplicate text (or not) to spanned columns // instead of setting duplicate span to empty string, use textExtraction to try to get a value // see http://stackoverflow.com/q/36449711/145346 txt = c . duplicateSpan || index === 0 ? val : typeof c . textExtraction !== 'string' ? ts . getElementText ( c , cell , cacheIndex + index ) || '' : '' ; rowData . raw [ cacheIndex + index ] = txt ; cols [ cacheIndex + index ] = txt ; index ++ ; } cacheIndex += span ; max += span ; } } cacheIndex ++ ; } // ensure rowData is always in the same location (after the last column) cols [ c . columns ] = rowData ; cache . normalized [ cache . normalized . length ] = cols ; } cache . colMax = colMax ; // total up rows, not including child rows c . totalRows += cache . normalized . length ; } if ( c . showProcessing ) { ts . isProcessing ( table ) ; // remove processing icon } if ( c . debug ) { len = Math . min ( 5 , c . cache [ 0 ] . normalized . length ) ; console [ console . group ? 'group' : 'log' ] ( 'Building cache for ' + c . totalRows + ' rows (showing ' + len + ' rows in log)' + ts . benchmark ( cacheTime ) ) ; val = { } ; for ( colIndex = 0 ; colIndex < c . columns ; colIndex ++ ) { for ( cacheIndex = 0 ; cacheIndex < len ; cacheIndex ++ ) { if ( ! val [ 'row: ' + cacheIndex ] ) { val [ 'row: ' + cacheIndex ] = { } ; } val [ 'row: ' + cacheIndex ] [ c . $headerIndexed [ colIndex ] . text ( ) ] = c . cache [ 0 ] . normalized [ cacheIndex ] [ colIndex ] ; } } console [ console . table ? 'table' : 'log' ] ( val ) ; if ( console . groupEnd ) { console . groupEnd ( ) ; } } if ( $ . isFunction ( callback ) ) { callback ( table ) ; } }


Input: / * ██ ██ █████▄ █████▄ ▄████▄ ██████ ██████ ██ ██ ██▄▄██ ██ ██ ██▄▄██ ██ ██▄▄ ██ ██ ██▀▀▀ ██ ██ ██▀▀██ ██ ██▀▀ ▀████▀ ██ █████▀ ██ ██ ██ ██████ [CODESPLIT] function ( c ) { var $sorted , indx , column , list = c . sortList , len = list . length , none = ts . css . sortNone + ' ' + c . cssNone , css = [ ts . css . sortAsc + ' ' + c . cssAsc , ts . css . sortDesc + ' ' + c . cssDesc ] , cssIcon = [ c . cssIconAsc , c . cssIconDesc , c . cssIconNone ] , aria = [ 'ascending' , 'descending' ] , // find the footer $headers = c . $table . find ( 'tfoot tr' ) . children ( 'td, th' ) . add ( $ ( c . namespace + '_extra_headers' ) ) . removeClass ( css . join ( ' ' ) ) ; // remove all header information c . $headers . removeClass ( css . join ( ' ' ) ) . addClass ( none ) . attr ( 'aria-sort' , 'none' ) . find ( '.' + ts . css . icon ) . removeClass ( cssIcon . join ( ' ' ) ) . addClass ( cssIcon [ 2 ] ) ; for ( indx = 0 ; indx < len ; indx ++ ) { // direction = 2 means reset! if ( list [ indx ] [ 1 ] !== 2 ) { // multicolumn sorting updating - see #1005 // .not(function(){}) needs jQuery 1.4 // filter(function(i, el){}) <- el is undefined in jQuery v1.2.6 $sorted = c . $headers . filter ( function ( i ) { // only include headers that are in the sortList (this includes colspans) var include = true , $el = c . $headers . eq ( i ) , col = parseInt ( $el . attr ( 'data-column' ) , 10 ) , end = col + c . $headers [ i ] . colSpan ; for ( ; col < end ; col ++ ) { include = include ? include || ts . isValueInArray ( col , c . sortList ) > - 1 : false ; } return include ; } ) ; // choose the :last in case there are nested columns $sorted = $sorted . not ( '.sorter-false' ) . filter ( '[data-column="' + list [ indx ] [ 0 ] + '"]' + ( len === 1 ? ':last' : '' ) ) ; if ( $sorted . length ) { for ( column = 0 ; column < $sorted . length ; column ++ ) { if ( ! $sorted [ column ] . sortDisabled ) { $sorted . eq ( column ) . removeClass ( none ) . addClass ( css [ list [ indx ] [ 1 ] ] ) . attr ( 'aria-sort' , aria [ list [ indx ] [ 1 ] ] ) . find ( '.' + ts . css . icon ) . removeClass ( cssIcon [ 2 ] ) . addClass ( cssIcon [ list [ indx ] [ 1 ] ] ) ; } } // add sorted class to footer & extra headers, if they exist if ( $headers . length ) { $headers . filter ( '[data-column="' + list [ indx ] [ 0 ] + '"]' ) . removeClass ( none ) . addClass ( css [ list [ indx ] [ 1 ] ] ) ; } } } } // add verbose aria labels len = c . $headers . length ; for ( indx = 0 ; indx < len ; indx ++ ) { ts . setColumnAriaLabel ( c , c . $headers . eq ( indx ) ) ; } }


Input: nextSort ( optional ) lets you disable next sort text [CODESPLIT] function ( c , $header , nextSort ) { if ( $header . length ) { var column = parseInt ( $header . attr ( 'data-column' ) , 10 ) , tmp = $header . hasClass ( ts . css . sortAsc ) ? 'sortAsc' : $header . hasClass ( ts . css . sortDesc ) ? 'sortDesc' : 'sortNone' , txt = $ . trim ( $header . text ( ) ) + ': ' + ts . language [ tmp ] ; if ( $header . hasClass ( 'sorter-false' ) || nextSort === false ) { txt += ts . language . sortDisabled ; } else { nextSort = c . sortVars [ column ] . order [ ( c . sortVars [ column ] . count + 1 ) % ( c . sortReset ? 3 : 2 ) ] ; // if nextSort txt += ts . language [ nextSort === 0 ? 'nextAsc' : nextSort === 1 ? 'nextDesc' : 'nextNone' ] ; } $header . attr ( 'aria-label' , txt ) ; } }


Input: simple header update - see #989 [CODESPLIT] function ( c , callback ) { c . table . isUpdating = true ; ts . buildHeaders ( c ) ; ts . bindEvents ( c . table , c . $headers , true ) ; ts . resortComplete ( c , callback ) ; }


Input: init flag ( true ) used by pager plugin to prevent widget application renamed from appendToTable [CODESPLIT] function ( c , init ) { var parsed , totalRows , $tbody , $curTbody , rowIndex , tbodyIndex , appendTime , table = c . table , wo = c . widgetOptions , $tbodies = c . $tbodies , rows = [ ] , cache = c . cache ; // empty table - fixes #206/#346 if ( ts . isEmptyObject ( cache ) ) { // run pager appender in case the table was just emptied return c . appender ? c . appender ( table , rows ) : table . isUpdating ? c . $table . triggerHandler ( 'updateComplete' , table ) : '' ; // Fixes #532 } if ( c . debug ) { appendTime = new Date ( ) ; } for ( tbodyIndex = 0 ; tbodyIndex < $tbodies . length ; tbodyIndex ++ ) { $tbody = $tbodies . eq ( tbodyIndex ) ; if ( $tbody . length ) { // detach tbody for manipulation $curTbody = ts . processTbody ( table , $tbody , true ) ; parsed = cache [ tbodyIndex ] . normalized ; totalRows = parsed . length ; for ( rowIndex = 0 ; rowIndex < totalRows ; rowIndex ++ ) { rows [ rows . length ] = parsed [ rowIndex ] [ c . columns ] . $row ; // removeRows used by the pager plugin; don't render if using ajax - fixes #411 if ( ! c . appender || ( c . pager && ( ! c . pager . removeRows || ! wo . pager_removeRows ) && ! c . pager . ajax ) ) { $curTbody . append ( parsed [ rowIndex ] [ c . columns ] . $row ) ; } } // restore tbody ts . processTbody ( table , $curTbody , false ) ; } } if ( c . appender ) { c . appender ( table , rows ) ; } if ( c . debug ) { console . log ( 'Rebuilt table' + ts . benchmark ( appendTime ) ) ; } // apply table widgets; but not before ajax completes if ( ! init && ! c . appender ) { ts . applyWidget ( table ) ; } if ( table . isUpdating ) { c . $table . triggerHandler ( 'updateComplete' , table ) ; } }


Input: / * ▄█████ ▄████▄ █████▄ ██████ ██ █████▄ ▄████▄ ▀█▄ ██ ██ ██▄▄██ ██ ██ ██ ██ ██ ▄▄▄ ▀█▄ ██ ██ ██▀██ ██ ██ ██ ██ ██ ▀██ █████▀ ▀████▀ ██ ██ ██ ██ ██ ██ ▀████▀ [CODESPLIT] function ( c , cell , event ) { if ( c . table . isUpdating ) { // let any updates complete before initializing a sort return setTimeout ( function ( ) { ts . initSort ( c , cell , event ) ; } , 50 ) ; } var arry , indx , headerIndx , dir , temp , tmp , $header , notMultiSort = ! event [ c . sortMultiSortKey ] , table = c . table , len = c . $headers . length , // get current column index col = parseInt ( $ ( cell ) . attr ( 'data-column' ) , 10 ) , order = c . sortVars [ col ] . order ; // Only call sortStart if sorting is enabled c . $table . triggerHandler ( 'sortStart' , table ) ; // get current column sort order c . sortVars [ col ] . count = event [ c . sortResetKey ] ? 2 : ( c . sortVars [ col ] . count + 1 ) % ( c . sortReset ? 3 : 2 ) ; // reset all sorts on non-current column - issue #30 if ( c . sortRestart ) { for ( headerIndx = 0 ; headerIndx < len ; headerIndx ++ ) { $header = c . $headers . eq ( headerIndx ) ; tmp = parseInt ( $header . attr ( 'data-column' ) , 10 ) ; // only reset counts on columns that weren't just clicked on and if not included in a multisort if ( col !== tmp && ( notMultiSort || $header . hasClass ( ts . css . sortNone ) ) ) { c . sortVars [ tmp ] . count = - 1 ; } } } // user only wants to sort on one column if ( notMultiSort ) { // flush the sort list c . sortList = [ ] ; c . last . sortList = [ ] ; if ( c . sortForce !== null ) { arry = c . sortForce ; for ( indx = 0 ; indx < arry . length ; indx ++ ) { if ( arry [ indx ] [ 0 ] !== col ) { c . sortList [ c . sortList . length ] = arry [ indx ] ; } } } // add column to sort list dir = order [ c . sortVars [ col ] . count ] ; if ( dir < 2 ) { c . sortList [ c . sortList . length ] = [ col , dir ] ; // add other columns if header spans across multiple if ( cell . colSpan > 1 ) { for ( indx = 1 ; indx < cell . colSpan ; indx ++ ) { c . sortList [ c . sortList . length ] = [ col + indx , dir ] ; // update count on columns in colSpan c . sortVars [ col + indx ] . count = $ . inArray ( dir , order ) ; } } } // multi column sorting } else { // get rid of the sortAppend before adding more - fixes issue #115 & #523 c . sortList = $ . extend ( [ ] , c . last . sortList ) ; // the user has clicked on an already sorted column if ( ts . isValueInArray ( col , c . sortList ) >= 0 ) { // reverse the sorting direction for ( indx = 0 ; indx < c . sortList . length ; indx ++ ) { tmp = c . sortList [ indx ] ; if ( tmp [ 0 ] === col ) { // order.count seems to be incorrect when compared to cell.count tmp [ 1 ] = order [ c . sortVars [ col ] . count ] ; if ( tmp [ 1 ] === 2 ) { c . sortList . splice ( indx , 1 ) ; c . sortVars [ col ] . count = - 1 ; } } } } else { // add column to sort list array dir = order [ c . sortVars [ col ] . count ] ; if ( dir < 2 ) { c . sortList [ c . sortList . length ] = [ col , dir ] ; // add other columns if header spans across multiple if ( cell . colSpan > 1 ) { for ( indx = 1 ; indx < cell . colSpan ; indx ++ ) { c . sortList [ c . sortList . length ] = [ col + indx , dir ] ; // update count on columns in colSpan c . sortVars [ col + indx ] . count = $ . inArray ( dir , order ) ; } } } } } // save sort before applying sortAppend c . last . sortList = $ . extend ( [ ] , c . sortList ) ; if ( c . sortList . length && c . sortAppend ) { arry = $ . isArray ( c . sortAppend ) ? c . sortAppend : c . sortAppend [ c . sortList [ 0 ] [ 0 ] ] ; if ( ! ts . isEmptyObject ( arry ) ) { for ( indx = 0 ; indx < arry . length ; indx ++ ) { if ( arry [ indx ] [ 0 ] !== col && ts . isValueInArray ( arry [ indx ] [ 0 ] , c . sortList ) < 0 ) { dir = arry [ indx ] [ 1 ] ; temp = ( '' + dir ) . match ( / ^(a|d|s|o|n) / ) ; if ( temp ) { tmp = c . sortList [ 0 ] [ 1 ] ; switch ( temp [ 0 ] ) { case 'd' : dir = 1 ; break ; case 's' : dir = tmp ; break ; case 'o' : dir = tmp === 0 ? 1 : 0 ; break ; case 'n' : dir = ( tmp + 1 ) % ( c . sortReset ? 3 : 2 ) ; break ; default : dir = 0 ; break ; } } c . sortList [ c . sortList . length ] = [ arry [ indx ] [ 0 ] , dir ] ; } } } } // sortBegin event triggered immediately before the sort c . $table . triggerHandler ( 'sortBegin' , table ) ; // setTimeout needed so the processing icon shows up setTimeout ( function ( ) { // set css for headers ts . setHeadersCss ( c ) ; ts . multisort ( c ) ; ts . appendCache ( c ) ; c . $table . triggerHandler ( 'sortBeforeEnd' , table ) ; c . $table . triggerHandler ( 'sortEnd' , table ) ; } , 1 ) ; }


Input: sort multiple columns [CODESPLIT] function ( c ) { /*jshint loopfunc:true */ var tbodyIndex , sortTime , colMax , rows , table = c . table , dir = 0 , textSorter = c . textSorter || '' , sortList = c . sortList , sortLen = sortList . length , len = c . $tbodies . length ; if ( c . serverSideSorting || ts . isEmptyObject ( c . cache ) ) { // empty table - fixes #206/#346 return ; } if ( c . debug ) { sortTime = new Date ( ) ; } for ( tbodyIndex = 0 ; tbodyIndex < len ; tbodyIndex ++ ) { colMax = c . cache [ tbodyIndex ] . colMax ; rows = c . cache [ tbodyIndex ] . normalized ; rows . sort ( function ( a , b ) { var sortIndex , num , col , order , sort , x , y ; // rows is undefined here in IE, so don't use it! for ( sortIndex = 0 ; sortIndex < sortLen ; sortIndex ++ ) { col = sortList [ sortIndex ] [ 0 ] ; order = sortList [ sortIndex ] [ 1 ] ; // sort direction, true = asc, false = desc dir = order === 0 ; if ( c . sortStable && a [ col ] === b [ col ] && sortLen === 1 ) { return a [ c . columns ] . order - b [ c . columns ] . order ; } // fallback to natural sort since it is more robust num = / n / i . test ( ts . getSortType ( c . parsers , col ) ) ; if ( num && c . strings [ col ] ) { // sort strings in numerical columns if ( typeof ( ts . string [ c . strings [ col ] ] ) === 'boolean' ) { num = ( dir ? 1 : - 1 ) * ( ts . string [ c . strings [ col ] ] ? - 1 : 1 ) ; } else { num = ( c . strings [ col ] ) ? ts . string [ c . strings [ col ] ] || 0 : 0 ; } // fall back to built-in numeric sort // var sort = $.tablesorter['sort' + s]( a[col], b[col], dir, colMax[col], table ); sort = c . numberSorter ? c . numberSorter ( a [ col ] , b [ col ] , dir , colMax [ col ] , table ) : ts [ 'sortNumeric' + ( dir ? 'Asc' : 'Desc' ) ] ( a [ col ] , b [ col ] , num , colMax [ col ] , col , c ) ; } else { // set a & b depending on sort direction x = dir ? a : b ; y = dir ? b : a ; // text sort function if ( typeof textSorter === 'function' ) { // custom OVERALL text sorter sort = textSorter ( x [ col ] , y [ col ] , dir , col , table ) ; } else if ( typeof textSorter === 'object' && textSorter . hasOwnProperty ( col ) ) { // custom text sorter for a SPECIFIC COLUMN sort = textSorter [ col ] ( x [ col ] , y [ col ] , dir , col , table ) ; } else { // fall back to natural sort sort = ts [ 'sortNatural' + ( dir ? 'Asc' : 'Desc' ) ] ( a [ col ] , b [ col ] , col , c ) ; } } if ( sort ) { return sort ; } } return a [ c . columns ] . order - b [ c . columns ] . order ; } ) ; } if ( c . debug ) { console . log ( 'Applying sort ' + sortList . toString ( ) + ts . benchmark ( sortTime ) ) ; } }


Input: Natural sort - https : // github . com / overset / javascript - natural - sort ( date sorting removed ) this function will only accept strings or you ll see TypeError : undefined is not a function I could add a = a . toString () ; b = b . toString () ; but it ll slow down the sort overall [CODESPLIT] function ( a , b ) { if ( a === b ) { return 0 ; } var aNum , bNum , aFloat , bFloat , indx , max , regex = ts . regex ; // first try and sort Hex codes if ( regex . hex . test ( b ) ) { aNum = parseInt ( a . match ( regex . hex ) , 16 ) ; bNum = parseInt ( b . match ( regex . hex ) , 16 ) ; if ( aNum < bNum ) { return - 1 ; } if ( aNum > bNum ) { return 1 ; } } // chunk/tokenize aNum = a . replace ( regex . chunk , '\\0$1\\0' ) . replace ( regex . chunks , '' ) . split ( '\\0' ) ; bNum = b . replace ( regex . chunk , '\\0$1\\0' ) . replace ( regex . chunks , '' ) . split ( '\\0' ) ; max = Math . max ( aNum . length , bNum . length ) ; // natural sorting through split numeric strings and default strings for ( indx = 0 ; indx < max ; indx ++ ) { // find floats not starting with '0', string or 0 if not defined aFloat = isNaN ( aNum [ indx ] ) ? aNum [ indx ] || 0 : parseFloat ( aNum [ indx ] ) || 0 ; bFloat = isNaN ( bNum [ indx ] ) ? bNum [ indx ] || 0 : parseFloat ( bNum [ indx ] ) || 0 ; // handle numeric vs string comparison - number < string - (Kyle Adams) if ( isNaN ( aFloat ) !== isNaN ( bFloat ) ) { return isNaN ( aFloat ) ? 1 : - 1 ; } // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2' if ( typeof aFloat !== typeof bFloat ) { aFloat += '' ; bFloat += '' ; } if ( aFloat < bFloat ) { return - 1 ; } if ( aFloat > bFloat ) { return 1 ; } } return 0 ; }


Input: return text string value by adding up ascii value so the text is somewhat sorted when using a digital sort this is NOT an alphanumeric sort [CODESPLIT] function ( val , num , max ) { if ( max ) { // make sure the text value is greater than the max numerical value (max) var indx , len = val ? val . length : 0 , n = max + num ; for ( indx = 0 ; indx < len ; indx ++ ) { n += val . charCodeAt ( indx ) ; } return num * n ; } return 0 ; }


Input: / * ██ ██ ██ ██ █████▄ ▄████▄ ██████ ██████ ▄█████ ██ ██ ██ ██ ██ ██ ██ ▄▄▄ ██▄▄ ██ ▀█▄ ██ ██ ██ ██ ██ ██ ██ ▀██ ██▀▀ ██ ▀█▄ ███████▀ ██ █████▀ ▀████▀ ██████ ██ █████▀ [CODESPLIT] function ( widget ) { if ( widget . id && ! ts . isEmptyObject ( ts . getWidgetById ( widget . id ) ) ) { console . warn ( '"' + widget . id + '" widget was loaded more than once!' ) ; } ts . widgets [ ts . widgets . length ] = widget ; }


Input: computeTableHeaderCellIndexes from : http : // www . javascripttoolbox . com / lib / table / examples . php http : // www . javascripttoolbox . com / temp / table_cellindex . html [CODESPLIT] function ( $rows , c ) { var i , j , k , l , cell , cells , rowIndex , rowSpan , colSpan , firstAvailCol , // total columns has been calculated, use it to set the matrixrow columns = c && c . columns || 0 , matrix = [ ] , matrixrow = new Array ( columns ) ; for ( i = 0 ; i < $rows . length ; i ++ ) { cells = $rows [ i ] . cells ; for ( j = 0 ; j < cells . length ; j ++ ) { cell = cells [ j ] ; rowIndex = cell . parentNode . rowIndex ; rowSpan = cell . rowSpan || 1 ; colSpan = cell . colSpan || 1 ; if ( typeof matrix [ rowIndex ] === 'undefined' ) { matrix [ rowIndex ] = [ ] ; } // Find first available column in the first row for ( k = 0 ; k < matrix [ rowIndex ] . length + 1 ; k ++ ) { if ( typeof matrix [ rowIndex ] [ k ] === 'undefined' ) { firstAvailCol = k ; break ; } } // jscs:disable disallowEmptyBlocks if ( columns && cell . cellIndex === firstAvailCol ) { // don't to anything } else if ( cell . setAttribute ) { // jscs:enable disallowEmptyBlocks // add data-column (setAttribute = IE8+) cell . setAttribute ( 'data-column' , firstAvailCol ) ; } else { // remove once we drop support for IE7 - 1/12/2016 $ ( cell ) . attr ( 'data-column' , firstAvailCol ) ; } for ( k = rowIndex ; k < rowIndex + rowSpan ; k ++ ) { if ( typeof matrix [ k ] === 'undefined' ) { matrix [ k ] = [ ] ; } matrixrow = matrix [ k ] ; for ( l = firstAvailCol ; l < firstAvailCol + colSpan ; l ++ ) { matrixrow [ l ] = 'x' ; } } } } return matrixrow . length ; }


Input: automatically add a colgroup with col elements set to a percentage width [CODESPLIT] function ( table ) { table = $ ( table ) [ 0 ] ; var overallWidth , percent , $tbodies , len , index , c = table . config , $colgroup = c . $table . children ( 'colgroup' ) ; // remove plugin-added colgroup, in case we need to refresh the widths if ( $colgroup . length && $colgroup . hasClass ( ts . css . colgroup ) ) { $colgroup . remove ( ) ; } if ( c . widthFixed && c . $table . children ( 'colgroup' ) . length === 0 ) { $colgroup = $ ( '<colgroup class="' + ts . css . colgroup + '">' ) ; overallWidth = c . $table . width ( ) ; // only add col for visible columns - fixes #371 $tbodies = c . $tbodies . find ( 'tr:first' ) . children ( ':visible' ) ; len = $tbodies . length ; for ( index = 0 ; index < len ; index ++ ) { percent = parseInt ( ( $tbodies . eq ( index ) . width ( ) / overallWidth ) * 1000 , 10 ) / 10 + '%' ; $colgroup . append ( $ ( '<col>' ) . css ( 'width' , percent ) ) ; } c . $table . prepend ( $colgroup ) ; } }


Input: get sorter string empty etc options for each column from jQuery data metadata header option or header class name ( sorter - false ) priority = jQuery data > meta > headers option > header class name [CODESPLIT] function ( header , configHeader , key ) { var meta , cl4ss , val = '' , $header = $ ( header ) ; if ( ! $header . length ) { return '' ; } meta = $ . metadata ? $header . metadata ( ) : false ; cl4ss = ' ' + ( $header . attr ( 'class' ) || '' ) ; if ( typeof $header . data ( key ) !== 'undefined' || typeof $header . data ( key . toLowerCase ( ) ) !== 'undefined' ) { // 'data-lockedOrder' is assigned to 'lockedorder'; but 'data-locked-order' is assigned to 'lockedOrder' // 'data-sort-initial-order' is assigned to 'sortInitialOrder' val += $header . data ( key ) || $header . data ( key . toLowerCase ( ) ) ; } else if ( meta && typeof meta [ key ] !== 'undefined' ) { val += meta [ key ] ; } else if ( configHeader && typeof configHeader [ key ] !== 'undefined' ) { val += configHeader [ key ] ; } else if ( cl4ss !== ' ' && cl4ss . match ( ' ' + key + '-' ) ) { // include sorter class name 'sorter-text', etc; now works with 'sorter-my-custom-parser' val = cl4ss . match ( new RegExp ( '\\s' + key + '-([\\w-]+)' ) ) [ 1 ] || '' ; } return $ . trim ( val ) ; }


Input: *** Process table *** add processing indicator [CODESPLIT] function ( $table , toggle , $headers ) { $table = $ ( $table ) ; var c = $table [ 0 ] . config , // default to all headers $header = $headers || $table . find ( '.' + ts . css . header ) ; if ( toggle ) { // don't use sortList if custom $headers used if ( typeof $headers !== 'undefined' && c . sortList . length > 0 ) { // get headers from the sortList $header = $header . filter ( function ( ) { // get data-column from attr to keep compatibility with jQuery 1.2.6 return this . sortDisabled ? false : ts . isValueInArray ( parseFloat ( $ ( this ) . attr ( 'data-column' ) ) , c . sortList ) >= 0 ; } ) ; } $table . add ( $header ) . addClass ( ts . css . processing + ' ' + c . cssProcessing ) ; } else { $table . add ( $header ) . removeClass ( ts . css . processing + ' ' + c . cssProcessing ) ; } }


Input: detach tbody but save the position don t use tbody because there are portions that look for a tbody index ( updateCell ) [CODESPLIT] function ( table , $tb , getIt ) { table = $ ( table ) [ 0 ] ; if ( getIt ) { table . isProcessing = true ; $tb . before ( '<colgroup class="tablesorter-savemyplace"/>' ) ; return $ . fn . detach ? $tb . detach ( ) : $tb . remove ( ) ; } var holdr = $ ( table ) . find ( 'colgroup.tablesorter-savemyplace' ) ; $tb . insertAfter ( holdr ) ; holdr . remove ( ) ; table . isProcessing = false ; }


Input: restore headers [CODESPLIT] function ( table ) { var index , $cell , c = $ ( table ) [ 0 ] . config , $headers = c . $table . find ( c . selectorHeaders ) , len = $headers . length ; // don't use c.$headers here in case header cells were swapped for ( index = 0 ; index < len ; index ++ ) { $cell = $headers . eq ( index ) ; // only restore header cells if it is wrapped // because this is also used by the updateAll method if ( $cell . find ( '.' + ts . css . headerIn ) . length ) { $cell . html ( c . headerContent [ index ] ) ; } } }


Input: mmddyyyy ddmmyyyy or yyyymmdd [CODESPLIT] function ( str ) { str = ( str || '' ) . replace ( ts . regex . spaces , ' ' ) . replace ( ts . regex . shortDateReplace , '/' ) ; return ts . regex . shortDateTest . test ( str ) ; }


Input: / * -- Coretags -- name : willHandle description : array of tags that the coretags plugin will handle [CODESPLIT] function ( Template ) { return [ Template . language . tag ( 'exit' ) , Template . language . tag ( 'exitloop' ) , Template . language . tag ( 'continue' ) ] ; }


Input: / * -- Coretags -- name : handleToken description : executed when any tag in willHandle is found [CODESPLIT] function ( Template , expression , tag ) { switch ( tag ) { case Template . language . tag ( 'exit' ) : return new Exit ( Template , expression ) ; case Template . language . tag ( 'continue' ) : return new Continue ( Template , expression ) ; case Template . language . tag ( 'exitloop' ) : return new Exit ( Template , expression , true ) ; default : return { skip : true } ; } }


Input: Returns false if node is a require expression where the module path ends with . js . [CODESPLIT] function checkCallExpression ( node ) { var callee = node . callee ; if ( callee . type === 'Identifier' && callee . name === 'require' ) { var pathNode = node . arguments [ 0 ] ; if ( pathNode . type === 'Literal' ) { var p = pathNode . value ; // Only check relatively-imported modules. if ( startswith ( p , [ '/' , './' , '../' ] ) ) { return ! endswith ( p , '.js' ) ; } } } return true ; }


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


Input: The Logia module . The returned value of require ( logia ) . [CODESPLIT] function ( name ) { var logger ; if ( LOGGERS [ name ] ) { logger = LOGGERS [ name ] ; } else { ActiveLoggerNameLengthHandler . update ( name ) ; logger = new Logia ( name ) ; LOGGERS [ name ] = logger ; } return logger ; }


Input: Listens for certain server events . Currently the only supported event is the log event which is triggered when Logia server receives a log . [CODESPLIT] function ( event , listener ) { switch ( event ) { case "log" : bus . subscribe ( EVENT_BUSLINE , { onRemoteLogReceived : function ( logObj ) { listener ( logObj ) ; } } ) ; break ; default : console . error ( "[LOGIA] Unknown event name: '" + event + "'" ) ; } }


Input: Create a instance of a GitCapsule . [CODESPLIT] function createGitRepository ( basePath , options ) { if ( typeof ( options ) === "undefined" ) options = defaultRepositoryOptions ; var gitRepository = new GitRepository ( ) ; configureGitRepository ( gitRepository , basePath , options ) ; return gitRepository ; }


Input: Recover a public key from a signature . [CODESPLIT] function recoverPubKey ( curve , e , signature , i ) { assert . strictEqual ( i & 3 , i , 'Recovery param is more than two bits' ) var n = curve . n var G = curve . G var r = signature . r var s = signature . s assert ( r . signum ( ) > 0 && r . compareTo ( n ) < 0 , 'Invalid r value' ) assert ( s . signum ( ) > 0 && s . compareTo ( n ) < 0 , 'Invalid s value' ) // A set LSB signifies that the y-coordinate is odd var isYOdd = i & 1 // The more significant bit specifies whether we should use the // first or second candidate key. var isSecondKey = i >> 1 // 1.1 Let x = r + jn var x = isSecondKey ? r . add ( n ) : r var R = curve . pointFromX ( isYOdd , x ) // 1.4 Check that nR is at infinity var nR = R . multiply ( n ) assert ( curve . isInfinity ( nR ) , 'nR is not a valid curve point' ) // Compute -e from e var eNeg = e . negate ( ) . mod ( n ) // 1.6.1 Compute Q = r^-1 (sR -  eG) //               Q = r^-1 (sR + -eG) var rInv = r . modInverse ( n ) var Q = R . multiplyTwo ( s , G , eNeg ) . multiply ( rInv ) curve . validate ( Q ) return Q }


Input: Calculate pubkey extraction parameter . [CODESPLIT] function calcPubKeyRecoveryParam ( curve , e , signature , Q ) { for ( var i = 0 ; i < 4 ; i ++ ) { var Qprime = recoverPubKey ( curve , e , signature , i ) // 1.6.2 Verify Q if ( Qprime . equals ( Q ) ) { return i } } throw new Error ( 'Unable to find valid recovery factor' ) }


Input: Scopes the url to the tournament or flight [CODESPLIT] function scopeUrl ( options , inst ) { options = _ . extend ( _ . clone ( options || { } ) , inst ) if ( typeof options !== 'object' && ( ! options . tournament_id || ! options . flight_id || ! options . league_id ) ) throw new Error ( 'tournament_id required to make StandingsDefault api calls' ) return options . tournament_id ? tournamentUrl ( options . tournament_id ) : leagueUrl ( options . league_id , options . game_type ) }


Input: allows additional permissions for this acl [CODESPLIT] function ( permissions ) { _ . merge ( this . permissions , permissions , function ( a , b ) { return _ . isArray ( a ) ? a . concat ( b ) : undefined ; } ) ; return this ; }


Input: Revoke a role [CODESPLIT] function ( roles ) { if ( ! Array . isArray ( roles ) ) { roles = [ roles ] ; } this . permissions = _ . reduce ( this . permissions , function ( result , actions , key ) { if ( roles . indexOf ( key ) === - 1 ) { result [ key ] = actions ; } return result ; } , { } ) ; return this ; }


Input: Assert access to this acl s action with role ( s ) [CODESPLIT] function ( roles , action ) { var self = this ; if ( ! action ) { action = roles ; roles = [ '*' ] ; } if ( ! Array . isArray ( roles ) ) { roles = [ roles ] ; } roles . push ( '*' ) ; var matches = _ . filter ( roles , function ( role ) { var actions = self . permissions [ role ] || self . permissions [ '*' ] ; return actions . indexOf ( action ) !== - 1 || actions . indexOf ( '*' ) !== - 1 ; } ) ; return matches . length > 0 ; }


Input: Returns a list of actions given role ( s ) have access to [CODESPLIT] function ( roles ) { roles = roles || [ '*' ] ; if ( ! Array . isArray ( roles ) ) { roles = [ roles ] ; } if ( roles . indexOf ( '*' ) === - 1 ) roles . push ( '*' ) ; var actions = [ ] ; _ . each ( roles , function ( role ) { if ( _ . has ( this . permissions , role ) ) { actions = actions . concat ( this . permissions [ role ] ) ; } } , this ) ; return _ . uniq ( actions ) ; }


Input: ----------- [CODESPLIT] function construct_uri_query ( parsee , alter_params ) { const this_uri_query = this ; const strategy = DEFAULT_STRATEGY ; Object . defineProperty ( this_uri_query , 'toString' , { value : to_string } ) ; if ( undefined !== parsee && null !== parsee ) { Object . assign ( this_uri_query , parse_parsee ( parsee , strategy , alter_params ) , ) ; // eslint-disable-line indent } return this_uri_query ; // ----------- function to_string ( ) { return compose_query_string ( this_uri_query , strategy , alter_params ) ; } }


Input: ----------- [CODESPLIT] function parse_query_string ( raw_query_string , strategy ) { const trimmed_raw_query_string = raw_query_string . trim ( ) ; if ( [ '' , '?' , '#' , '?#' ] . includes ( trimmed_raw_query_string ) ) { return { } ; } const hash_index = trimmed_raw_query_string . indexOf ( '#' ) ; /* eslint-disable indent */ const query_string = trimmed_raw_query_string . substring ( '?' === trimmed_raw_query_string . substring ( 0 , 1 ) ? 1 : 0 , - 1 === hash_index ? undefined : hash_index , ) . replace ( / (?:^[&\s]+|[&\s]+$) / g , '' ) // trim white space and &'s . replace ( / [&\s]*&[&\s]* / g , '&' ) ; /* eslint-enable indent */ if ( '' === query_string ) { return { } ; } return strategy . parse_query_string ( query_string ) ; }


Input: ----------- [CODESPLIT] function protect_proto ( parsed_query_object ) { const unsafe_keys = Object . getOwnPropertyNames ( Object . prototype ) ; const safe_query_object = Object . assign ( { } , parsed_query_object ) ; for ( const key of unsafe_keys ) { '__proto__' !== key // __proto__ is ignored by javascript && undefined !== safe_query_object [ key ] && safe_query_object [ key ] !== Object . prototype [ key ] && protect_prop ( key ) ; // eslint-disable-line indent } return safe_query_object ; // ----------- function protect_prop ( key ) { safe_query_object [ ` ${ key } ` ] = safe_query_object [ key ] ; delete safe_query_object [ key ] ; return true ; } }


Input: ----------- [CODESPLIT] function unprotect_prop ( unsafe_key , safe_key ) { unsafe_query_object [ unsafe_key ] = unsafe_query_object [ safe_key ] ; delete unsafe_query_object [ safe_key ] ; return true ; }


Input: ----------- [CODESPLIT] function alter_query_object ( mode , query_object , alter_params ) { const altered_object = Object . assign ( { } , query_object ) ; const query_keys = Object . keys ( query_object ) ; const alter_keys = Object . keys ( alter_params ) ; for ( const key of alter_keys ) { if ( query_keys . includes ( key ) ) { const alter_value = alter_params [ key ] ; /* eslint-disable indent */ const perform_alteration = 'parse' === mode ? 'function' === typeof alter_value ? alter_value : 'function' === typeof alter_value . parse ? alter_value . parse : dont_alter : 'compose' === mode ? 'function' === typeof alter_value . compose ? alter_value . compose : dont_alter : dont_alter ; /* eslint-ensable indent */ altered_object [ key ] = perform_alteration ( altered_object [ key ] ) ; } } return altered_object ; }


Input: / * Receiver stream [CODESPLIT] function ( options ) { options = options || { } ; this . maxLen = options . maxLen || 20 ; //how many packets can be buffered before stopping acknowledging new packets this . ops = [ ] ; this . seq = 0 ; this . drained = true ; this . _send = function ( op ) { } ; }


Input: / * Sender stream [CODESPLIT] function ( options ) { options = options || { } ; this . retryTimeout = options . retryTimeout || 10000 ; this . maxNotAck = options . maxNotAck || 10 ; //how many unacknowledged packets can be in fly this . ops = [ ] ; this . seq = 0 ; this . sentSeq = 0 ; //the last packet which was sent, but still not acknowledged this . lastSend = 0 ; this . _send = function ( op ) { } ; }


Input: / * OpStream [CODESPLIT] function ( options ) { var opStream = this ; options = options || { } ; this . pingIntervalMs = options . pingIntervalMs || 5000 ; this . pingTimeoutMs = options . pingTimeoutMs || 3000 ; this . inStream = new InStream ( { maxLen : options . inMaxLen } ) ; this . outStream = new OutStream ( { retryTimeout : options . outRetryTimeout , maxNotAck : options . outMaxNotAck } ) ; this . inStream . _send = this . _send . bind ( this ) ; this . outStream . _send = this . _send . bind ( this ) ; this . inStream . onReadable = function ( ) { if ( opStream . onReadable ) opStream . onReadable ( ) ; } ; this . onReadable = null ; this . onOnline = null ; this . onOffline = null ; this . lastPing = 0 ; this . connectionStatus = 'online' ; this . paused = false ; this . timerInterval = null ; this . pingTimeout = null ; this . initTimer ( ) ; }


Input: DAO implementation . [CODESPLIT] function DAOImplementation ( config ) { let basePath = config . basePath || 'backend/persistence/catalog/' ; let isDBloaded = true ; if ( config . filename ) { config . filename = basePath + config . filename ; } if ( config . schema ) { this . schema = fs . readJSON ( path . join ( appRoot . toString ( ) , basePath , config . schema ) ) ; } else { this . schema = { } ; } let db = new DataStore ( config ) ; if ( config . filename && ! config . autoload ) { isDBloaded = false ; } this . collection = db ; this . isDBloaded = isDBloaded ; }


Input: Model implementation based on Backbone . js Model implementation . [CODESPLIT] function Model ( attributes ) { // Set events hash now to prevent proxy trap this . _events = { } ; // Call super constructor EventEmitter . call ( this ) ; attributes = attributes || { } ; // Separator for change events this . _separator = ':' ; // Internal Object for storing attributes this . attributes = { } ; // Attributes that have changed since the last `change` was called. this . _changed = { } ; // Hash of attributes that have changed silently since the last `change` // was called. this . _silent = { } ; // Hash of changed attributes that have changed since the last `change` // call began. this . _pending = { } ; // Set initial attributes silently this . set ( attributes , { silent : true } ) ; // Reset changes this . _changes = { } ; this . _silent = { } ; this . _pending = { } ; // Keep track of previous values (before the previous change call) this . _previous = _ . clone ( this . attributes ) ; // Call initialize logic this . initialize . apply ( this , arguments ) ; }


Input: ProxiedModel constructor . This will return a ProxyHandle to act as a Proxy for the created model . [CODESPLIT] function ProxiedModel ( attributes ) { var model ; if ( attributes instanceof Model ) { // Use existing model model = attributes ; } else { // Create a new Model model = new Model ( attributes ) ; } // Return the Proxy handler return createModelProxy ( model ) ; }


Input: Create a Proxy for a Model . This function will return a new Proxy handle for the given Model . [CODESPLIT] function createModelProxy ( model ) { // Create a Proxy handle var handle = { getOwnPropertyDescriptor : function ( target , name ) { return ObjProto . getOwnPropertyDescriptor . call ( model . attributes , name ) ; } , getOwnPropertyNames : function ( target ) { return ObjProto . getOwnPropertyNames . call ( model . attributes ) ; } , defineProperty : function ( name , propertyDescriptor ) { return Object . defineProperty ( model . attributes , name , propertyDescriptor ) ; } , // Get an attribute from the Model. This will first check for Model properties before // checking the Model's internal attributes map. get : function ( target , name , reciever ) { // Check for direct properties to satisfy internal attribute and function calls if ( model [ name ] ) { return model [ name ] ; } // It's not a property, check for internal attribute value return model . get ( name ) ; } , set : function ( target , name , value , receiver ) { return model . set ( name , value ) ; } , delete : function ( name ) { model . unset ( name ) ; } , has : function ( target , name ) { return model . has ( 'name' ) ; } , hasOwn : function ( target , name ) { return this . has ( target , name ) ; } , enumerate : function ( target ) { return model . attributes ; } , keys : function ( target ) { return Object . keys ( model . attributes ) ; } //protect: function(operation, target) -> boolean //stopTrapping: function(target) -> boolean //iterate: not implemented yet } ; return ProxyCtor . create ( handle , Model ) ; }


Input: Get an attribute from the Model . This will first check for Model properties before checking the Model s internal attributes map . [CODESPLIT] function ( target , name , reciever ) { // Check for direct properties to satisfy internal attribute and function calls if ( model [ name ] ) { return model [ name ] ; } // It's not a property, check for internal attribute value return model . get ( name ) ; }


Input: Private functions . [CODESPLIT] function detectDestType ( dest ) { if ( grunt . util . _ . endsWith ( dest , '/' ) ) { return cnst . directory ; } else { return cnst . file ; } }


Input: RANDOM // FUNCTION : random ( len mu sigma [ rand ] ) Creates an array of normally distributed random numbers . [CODESPLIT] function random ( len , mu , sigma , rand ) { var out ; var draw ; var i ; draw = partial ( mu , sigma , rand ) ; // Ensure fast elements... if ( len < 64000 ) { out = new Array ( len ) ; for ( i = 0 ; i < len ; i ++ ) { out [ i ] = draw ( ) ; } } else { out = [ ] ; for ( i = 0 ; i < len ; i ++ ) { out . push ( draw ( ) ) ; } } return out ; }


Input: FUNCTION : roundn ( x n ) Rounds values to the nearest multiple of 10^n . Notes : if provided an array mutates the array . [CODESPLIT] function roundn ( x , n ) { var isArray = Array . isArray ( x ) , scalar , len ; if ( ! isArray && ( typeof x !== 'number' || x !== x ) ) { throw new TypeError ( 'roundn()::invalid input argument. Must provide either a single numeric value or a numeric array.' ) ; } if ( typeof n !== 'number' || n !== n || n !== ( n | 0 ) ) { throw new TypeError ( 'roundn()::invalid input argument. Power of 10 must be an integer value.' ) ; } n = - n ; scalar = Math . pow ( 10 , n ) ; if ( ! isArray ) { return Math . round ( x * scalar ) / scalar ; } len = x . length ; if ( ! len ) { return null ; } for ( var i = 0 ; i < len ; i ++ ) { x [ i ] = Math . round ( x [ i ] * scalar ) / scalar ; } return x ; }


Input: Get a random color [CODESPLIT] function ( ) { return { r : Math . floor ( Math . random ( ) * 256 ) , g : Math . floor ( Math . random ( ) * 256 ) , b : Math . floor ( Math . random ( ) * 256 ) , a : 255 } ; }


Input: Pingy constructor [CODESPLIT] function ( width , height ) { width = clamp ( width , 1 ) ; height = clamp ( height , 1 ) ; this . _png = new PNG ( ) ; this . _png . width = width ; this . _png . height = height ; this . _png . data = buffer ( width , height ) ; this . forEachPoint ( function ( x , y , rgba ) { return { r : 0 , g : 0 , b : 0 , a : 255 } ; } ) ; }


Input: Execute a function on each point in an image [CODESPLIT] function ( fn ) { for ( var y = 0 ; y < this . getHeight ( ) ; y ++ ) { for ( var x = 0 ; x < this . getWidth ( ) ; x ++ ) { var rgba = this . getColor ( x , y ) ; var out = fn . call ( this , x , y , rgba ) ; this . setColor ( x , y , ( out || rgba ) ) ; } } return this ; }


Input: Get the RGBA value of a coordinate [CODESPLIT] function ( x , y ) { var i = this . _getIndex ( x , y ) ; return { r : this . _png . data [ i + 0 ] , g : this . _png . data [ i + 1 ] , b : this . _png . data [ i + 2 ] , a : this . _png . data [ i + 3 ] } ; }


Input: Set the RGBA value of a coordinate [CODESPLIT] function ( x , y , rgba ) { var i = this . _getIndex ( x , y ) ; var prev = this . getColor ( x , y ) ; this . _png . data [ i + 0 ] = is_num ( rgba . r ) ? to_rgba_int ( rgba . r ) : prev . r ; this . _png . data [ i + 1 ] = is_num ( rgba . g ) ? to_rgba_int ( rgba . g ) : prev . g ; this . _png . data [ i + 2 ] = is_num ( rgba . b ) ? to_rgba_int ( rgba . b ) : prev . b ; this . _png . data [ i + 3 ] = is_num ( rgba . a ) ? to_rgba_int ( rgba . a ) : prev . a ; return this . getColor ( x , y ) ; }


Input: Enlarge by some integer factor [CODESPLIT] function ( factor ) { factor = clamp ( to_int ( factor ) , 1 ) ; var width = this . getWidth ( ) * factor ; var height = this . getHeight ( ) * factor ; var buf = new buffer ( width , height ) ; for ( var y = 0 ; y < height ; y ++ ) { for ( var x = 0 ; x < width ; x ++ ) { var i = get_index ( width , x , y ) ; var rgba = this . getColor ( to_int ( x / factor ) , to_int ( y / factor ) ) ; buf [ i + 0 ] = rgba . r ; buf [ i + 1 ] = rgba . g ; buf [ i + 2 ] = rgba . b ; buf [ i + 3 ] = rgba . a ; } } this . _png . width = width ; this . _png . height = height ; this . _png . data = buf ; return this ; }


Input: Get the base64 encoding [CODESPLIT] function ( fn ) { fn = fn || console . log . bind ( console ) ; var buffers = [ ] ; var base64 = new Stream ( ) ; base64 . readable = base64 . writable = true ; base64 . write = function ( data ) { buffers . push ( data ) ; } ; base64 . end = function ( ) { fn ( Buffer . concat ( buffers ) . toString ( 'base64' ) ) ; } this . _png . pack ( ) . pipe ( base64 ) ; }


Input: Get the base64 encoding as a data URI [CODESPLIT] function ( fn ) { fn = fn || console . log . bind ( console ) ; return this . toBase64 ( function ( str ) { fn ( 'data:image/png;base64,' + str ) ; } ) ; }


Input: This is a node - specific version of an anal structural equality test modeled on bits and pieces of many other versions of this check most notably deeper which is in turn based on the Node . js source s assert . deepEqual and the Underscore library . It doesn t throw and handles cycles . [CODESPLIT] function deepest ( a , b , ca , cb ) { if ( a === b ) { return true ; } else if ( typeof a !== 'object' || typeof b !== 'object' ) { return false ; } else if ( a === null || b === null ) { return false ; } else if ( Buffer . isBuffer ( a ) && Buffer . isBuffer ( b ) ) { if ( fastEqual ) { return fastEqual . call ( a , b ) ; } else { if ( a . length !== b . length ) return false ; for ( var i = 0 ; i < a . length ; i ++ ) if ( a [ i ] !== b [ i ] ) return false ; return true ; } } else if ( a instanceof Date && b instanceof Date ) { return a . getTime ( ) === b . getTime ( ) ; } else if ( isArguments ( a ) || isArguments ( b ) ) { if ( ! ( isArguments ( a ) && isArguments ( b ) ) ) return false ; var slice = Array . prototype . slice ; return deepest ( slice . call ( a ) , slice . call ( b ) , ca , cb ) ; } else { if ( a . constructor !== b . constructor ) return false ; var pa = Object . getOwnPropertyNames ( a ) ; var pb = Object . getOwnPropertyNames ( b ) ; if ( pa . length !== pb . length ) return false ; var cal = ca . length ; while ( cal -- ) if ( ca [ cal ] === a ) return cb [ cal ] === b ; ca . push ( a ) ; cb . push ( b ) ; pa . sort ( ) ; pb . sort ( ) ; for ( var j = pa . length - 1 ; j >= 0 ; j -- ) if ( pa [ j ] !== pb [ j ] ) return false ; var name , da , db ; for ( var k = pa . length - 1 ; k >= 0 ; k -- ) { name = pa [ k ] ; da = Object . getOwnPropertyDescriptor ( a , name ) ; db = Object . getOwnPropertyDescriptor ( b , name ) ; if ( da . enumerable !== db . enumerable || da . writable !== db . writable || da . configurable !== db . configurable || da . get !== db . get || da . set !== db . set ) { return false ; } if ( ! deepest ( da . value , db . value , ca , cb ) ) return false ; } ca . pop ( ) ; cb . pop ( ) ; return true ; } }


Input: copied straight from tap - test . js [CODESPLIT] function assertParasite ( fn ) { return function _deeperAssert ( ) { if ( this . _bailedOut ) return ; var res = fn . apply ( tap . assert , arguments ) ; this . result ( res ) ; return res ; } ; }


Input: Performs rot13 encoding / decoding [CODESPLIT] function rot13 ( str ) { return str . replace ( / [a-zA-Z] / g , function ( c ) { return String . fromCharCode ( ( c <= 'Z' ? 90 : 122 ) >= ( c = c . charCodeAt ( 0 ) + 13 ) ? c : c - 26 ) ; } ) ; }


Input: Swaps all tags with a class of obfuscemail with an <a > mailto link [CODESPLIT] function swapTags ( email , text ) { document . querySelectorAll ( '.obfuscemail' ) . forEach ( function ( a ) { var newA = document . createElement ( 'a' ) ; newA . href = 'mailto:' + email ; newA . innerHTML = text ; a . parentNode . replaceChild ( newA , a ) ; } ) ; }


Input: RANDOM // FUNCTION : random ( dims dt mu sigma [ rand ] ) Creates a matrix of normally distributed random numbers . [CODESPLIT] function random ( dims , dt , mu , sigma , rand ) { var out ; var draw ; var i ; draw = partial ( mu , sigma , rand ) ; out = matrix ( dims , dt ) ; for ( i = 0 ; i < out . length ; i ++ ) { out . data [ i ] = draw ( ) ; } return out ; }


Input: Validates ignore option for given path [CODESPLIT] function getIgnored ( filepath ) { for ( var i in options . ignore ) { if ( filepath . indexOf ( options . ignore [ i ] ) !== - 1 ) { return options . ignore [ i ] ; } } return null ; }


Input: Tells whether or not the given path is a valid directory ( directory which contains a package . json ) [CODESPLIT] function isValidDir ( filepath ) { if ( grunt . file . isDir ( filepath ) ) { return grunt . file . exists ( path . resolve ( filepath , 'package.json' ) ) ; } return false ; }


Input: utils [CODESPLIT] function bindify ( fn , thisArg , args ) { return fn . bind . apply ( fn , [ thisArg ] . concat ( args ) ) }


Input: ------------------------------------------------------------------------------ [CODESPLIT] function defineGetStageValue ( parts ) { let body ; switch ( parts . length ) { case 0 : body = "return this.state;" ; break ; default : const lastIndex = parts . length - 1 ; body = "var tmp0 = this.state;" ; for ( let i = 0 ; i < lastIndex ; ++ i ) { body += ` ${ i } ${ i + 1 } ${ i } ${ parts [ i ] } ` ; } body += ` ${ lastIndex } ${ lastIndex } ${ parts [ lastIndex ] } ` ; break ; } return Function ( body ) ; }


Input: ------------------------------------------------------------------------------ [CODESPLIT] function defineSetStageValue ( parts ) { let body = ` ` ; switch ( parts . length ) { case 0 : body += "\nthis.setState(value, cb2);" ; break ; case 1 : body += ` \n ${ parts [ 0 ] } ` ; break ; default : const lastIndex = parts . length - 1 ; body += ` \n ` ; for ( let i = 0 ; i < lastIndex ; ++ i ) { body += ` ${ i + 1 } ${ i } ${ parts [ i ] } ${ i + 1 } ${ i + 1 } ${ i } ${ parts [ i ] } ` ; } body += ` ${ lastIndex } ${ parts [ lastIndex ] } ` ; break ; } return Function ( "value" , "cb" , body ) ; }


Input: ------------------------------------------------------------------------------ [CODESPLIT] function handleSendAction ( event ) { if ( event . defaultPrevented ) { return ; } if ( typeof this . filterAction === "function" && ! this . filterAction ( event ) ) { return ; } event . stopPropagation ( ) ; event . applyTo ( this ) ; }


Input: @constructor [CODESPLIT] function Mongootils ( ) { if ( arguments [ 0 ] && arguments [ 0 ] . constructor && arguments [ 0 ] . constructor . name === 'NativeConnection' ) { this . connection = arguments [ 0 ] ; this . uri = this . getConnectionURI ( ) ; this . options = this . connection . options ; } else { this . uri = arguments [ 0 ] ; this . options = arguments [ 1 ] ; } }


Input:
PARTIAL // FUNCTION : partial ( mu sigma [ rand ] ) Partially applies mu and sigma and returns a function to generate random variables from the normal distribution . Implementation of the Improved Ziggurat Method by J . Doornik . Reference : Doornik J . a . ( 2005 ) . An Improved Ziggurat Method to Generate Normal Random Samples . [CODESPLIT] function partial ( mu , sigma , rand ) { var random ; /* s_adZigX holds coordinates, such that each rectangle has
		same area; s_adZigR holds s_adZigX[i + 1] / s_adZigX[i] */ var s_adZigX = new Array ( ZIGNOR_C + 1 ) ; var s_adZigR = new Array ( ZIGNOR_C ) ; var i ; var f ; if ( rand ) { random = rand ; } else { random = Math . random ; } f = exp ( - 0.5 * ZIGNOR_R * ZIGNOR_R ) ; s_adZigX [ 0 ] = ZIGNOR_V / f ; /* [0] is bottom block: V / f(R) */ s_adZigX [ 1 ] = ZIGNOR_R ; s_adZigX [ ZIGNOR_C ] = 0 ; for ( i = 2 ; i < ZIGNOR_C ; i ++ ) { s_adZigX [ i ] = sqrt ( - 2 * log ( ZIGNOR_V / s_adZigX [ i - 1 ] + f ) ) ; f = exp ( - 0.5 * s_adZigX [ i ] * s_adZigX [ i ] ) ; } for ( i = 0 ; i < ZIGNOR_C ; i ++ ) { s_adZigR [ i ] = s_adZigX [ i + 1 ] / s_adZigX [ i ] ; } /**
	* FUNCTION: draw( x )
	*	Generates a random draw for a normal distribution with parameters `mu` and `sigma`.
	*
	* @private
	* @returns {Number} random draw from the specified distribution
	*/ return function draw ( ) { var x , u , f0 , f1 ; for ( ; ; ) { u = 2 * random ( ) - 1 ; i = TWO_P_32 * random ( ) & 0x7F ; /* first try the rectangular boxes */ if ( abs ( u ) < s_adZigR [ i ] ) { return mu + sigma * u * s_adZigX [ i ] ; } /* bottom box: sample from the tail */ if ( i === 0 ) { return mu + sigma * dRanNormalTail ( ZIGNOR_R , u < 0 , rand ) ; } /* is this a sample from the wedges? */ x = u * s_adZigX [ i ] ; f0 = exp ( - 0.5 * ( s_adZigX [ i ] * s_adZigX [ i ] - x * x ) ) ; f1 = exp ( - 0.5 * ( s_adZigX [ i + 1 ] * s_adZigX [ i + 1 ] - x * x ) ) ; if ( f1 + random ( ) * ( f0 - f1 ) < 1.0 ) { return mu + sigma * x ; } } } ; // end FUNCTION draw() }


Input: Basic input prompt rendering . [CODESPLIT] function renderInputPrompt ( ) { process . stdout . write ( prefix ) ; process . stdout . write ( textToRender . join ( '' ) ) ; }


Input: Will return a chalk function based on selected index etc .. [CODESPLIT] function calculateFieldColor ( selectedColor , nonSelectedColor , focusedColor , index , out ) { if ( selected . indexOf ( index ) !== - 1 && focused == index ) return chalk . bold . rgb ( selectedColor . r , selectedColor . g , selectedColor . b ) ( out ) ; if ( selected . indexOf ( index ) !== - 1 ) // this goes before focused so selected color gets priority over focused values return chalk . rgb ( selectedColor . r , selectedColor . g , selectedColor . b ) ( out ) ; if ( focused == index ) return chalk . bold . rgb ( focusedColor . r , focusedColor . g , focusedColor . b ) ( out ) ; return chalk . rgb ( nonSelectedColor . r , nonSelectedColor . g , nonSelectedColor . b ) ( out ) ; }


Input: FUNCTION randn ( length ) Creates an array of standard normal random variates using the Box - Mueller transform . [CODESPLIT] function randn ( length ) { var urand , vrand , vec = [ ] , numValues = length || 1 ; for ( var i = 0 ; i < numValues ; i ++ ) { urand = Math . random ( ) ; vrand = Math . random ( ) ; vec . push ( Math . sqrt ( - 2 * Math . log ( urand ) ) * Math . cos ( 2 * Math . PI * vrand ) ) ; } if ( numValues === 1 ) { return vec [ 0 ] ; } return vec ; }


Input: Use app . import to add additional libraries to the generated output files . If you need to use different assets in different environments specify an object as the first parameter . That object s keys should be the environment name and the values should be the asset to use in that environment . If the library that you are including contains AMD or ES6 modules that you would like to import into your application please specify an object with the list of modules as keys along with the exports of each module as its value . [CODESPLIT] function render ( errors ) { if ( ! errors ) { return '' ; } ; return errors . map ( function ( error ) { return error . line + ':' + error . column + ' ' + ' - ' + error . message + ' (' + error . ruleId + ')' ; } ) . join ( '\n' ) ; }


Input: Handle GET request . [CODESPLIT] function ( url ) { let request = parseRequest ( url ) ; let resource = getRequestedResource ( request ) ; return resource . get ( request ) . then ( returnGetResponse ) ; function returnGetResponse ( result ) { // eslint-disable-line require-jsdoc return new RESTResponse ( url , "GET" , result ) ; } }


Input: Handle PUT request . [CODESPLIT] function ( url , data ) { let request = parseRequest ( url , data ) ; let resource = getRequestedResource ( request ) ; return resource . put ( request ) . then ( returnResponse ) ; function returnResponse ( result ) { // eslint-disable-line require-jsdoc return new RESTResponse ( url , "PUT" , result ) ; } }


Input: FUNCTION : recurse ( dims d draw ) Recursively create a multidimensional array of normally distributed random numbers . [CODESPLIT] function recurse ( dims , d , draw ) { var out = [ ] ; var len ; var i ; len = dims [ d ] ; d += 1 ; if ( d < dims . length ) { for ( i = 0 ; i < len ; i ++ ) { out . push ( recurse ( dims , d , draw ) ) ; } } else { for ( i = 0 ; i < len ; i ++ ) { out . push ( draw ( ) ) ; } } return out ; }


Input: Returns a copy of the input in which any property that hasn t explicitly been expressed in the schema is stripped . [CODESPLIT] function mapPrune ( input , schema ) { var result = { } ; _ . forOwn ( schema , function ( value , key ) { if ( _ . isPlainObject ( value ) ) { // Recursive. result [ key ] = mapPrune ( input [ key ] || { } , value ) ; } else { // Base. Null is set as the default value. result [ key ] = input [ key ] || null ; } } ) ; return result ; }


Input: Returns a result map of running the schema s tests / transformers against an input object . [CODESPLIT] function mapRun ( input , schema , discrepencies ) { var result = { } ; _ . forOwn ( schema , function ( value , key ) { if ( _ . isPlainObject ( value ) ) { // Recursive. Others are bases. result [ key ] = mapRun ( input [ key ] , value , discrepencies ) ; } else if ( _ . isArray ( value ) ) { try { result [ key ] = value . reduce ( function ( prev , curr , index ) { if ( ! _ . isFunction ( curr ) ) throw 'Index [' + index + ']: Not a function.' ; return curr ( prev ) ; } , input [ key ] ) ; } catch ( e ) { discrepencies . push ( '' + key + ': ' + e ) ; } } else if ( _ . isFunction ( value ) ) { try { result [ key ] = value ( input [ key ] ) ; // Result of running that function against the input. } catch ( e ) { discrepencies . push ( '' + key + ': ' + e ) ; } } else { throw new TypeError ( 'Schemas should be a nested object of functions or function arrays.' ) ; } } ) ; return result ; }


Input: Transform a given input value using a property spec object . propSpec : an object that defines a Backprop property . Supported keys ( see the README for explanations ) include : coerce choices trim max min inputVal : the value that the caller has assigned to the property fallbackValue ( optional ) : a default value to use if the input is invalid [CODESPLIT] function transformValue ( propSpec , inputVal , fallbackValue ) { var value = inputVal ; if ( typeof propSpec . coerce === 'function' ) value = propSpec . coerce ( value ) ; // If an array of choices was passed in, validate that the input is one of // the valid choices: var choices = propSpec . choices ; if ( choices && choices . constructor && choices . constructor . name === 'Array' ) { if ( choices . indexOf ( value ) === - 1 ) { if ( fallbackValue !== undefined ) value = fallbackValue ; else return undefined ; } } if ( propSpec . trim && ( typeof value . trim === 'function' ) ) value = value . trim ( ) ; if ( propSpec . max && ( value > propSpec . max ) ) value = propSpec . max ; if ( propSpec . min && ( value < propSpec . min ) ) value = propSpec . min ; return value ; }


Input: Allow use of shorthand properties like myprop : Backprop . Boolean () . This avoids having to pass in an explicit coerce function when you are just casting to a JS type . If you do pass in a coerce function it will still work but the type cast will be applied first . [CODESPLIT] function ( typeCoerce ) { return function ( specObj ) { specObj = specObj || { } ; var innerCoerce = specObj . coerce ; if ( typeof innerCoerce === 'function' ) { specObj . coerce = function ( x ) { return innerCoerce ( typeCoerce ( x ) ) ; } ; } else { specObj . coerce = typeCoerce ; } return new PropPlaceholder ( specObj ) ; } ; }


Input: Retrieves a palette from theme references . Is defined as {{ paletteName }} . {{ palette . property }} | {{ colorManipulation }} Example : # theme . yaml color : !palette primary . color|accent [CODESPLIT] function ( values , yamlLoader ) { var palettes = luiTheme ( 'core.references.palettes' ) , palette = values . split ( '|' ) [ 0 ] , paletteName = palette . split ( '.' ) [ 0 ] , paletteProp = ( palette . split ( '.' ) [ 1 ] ) ? palette . split ( '.' ) [ 1 ] : null , manipulation = ( values . split ( '|' ) [ 1 ] ) ? values . split ( '|' ) [ 1 ] : null , result = palettes . colors [ paletteName ] ; if ( paletteProp && result [ paletteProp ] ) result = result [ paletteProp ] ; if ( manipulation ) { result = palettes . manipulations [ manipulation ] [ 0 ] + '(' + result + ', ' + palettes . manipulations [ manipulation ] [ 1 ] + ')' ; } return result ; }


Input: Creates the YAML schema based on default and passed custom types . [CODESPLIT] function createYamlSchema ( customTypes ) { var yamlTypes = [ ] ; _ . each ( customTypes , function ( resolver , tagAndKindString ) { var tagAndKind = tagAndKindString . split ( / \s+ / ) , yamlType = new yaml . Type ( tagAndKind [ 0 ] , { kind : tagAndKind [ 1 ] , construct : function ( data ) { var result = resolver . call ( this , data , loadYamlFile ) ; if ( _ . isUndefined ( result ) || _ . isFunction ( result ) ) { return null ; } else { return result ; } } } ) ; yamlTypes . push ( yamlType ) ; } ) ; return yaml . Schema . create ( yamlTypes ) ; }


Input: Loads a YAML file and parses it into an Object . [CODESPLIT] function loadYamlFile ( filepath ) { try { return yaml . safeLoad ( fs . readFileSync ( filepath ) , { schema : yamlSchema , filename : filepath } ) ; } catch ( err ) { return null ; } }


Input: Load theme variables from a YAML file . [CODESPLIT] function loadTheme ( props ) { var relPath = '/' + props . join ( '/' ) + '.yml' , defaultsPath = path . resolve ( base + '/scss/themes/default' + relPath ) , customPath = ( custom ) ? custom + relPath : null , defaultVars = { } , customVars = null , result = { } ; // Try loading a custom theme file customVars = loadYamlFile ( customPath ) ; // If merge mode is set to "replace", don't even load the defaults if ( customVars && customVars [ 'merge-mode' ] === 'replace' ) { result = _ . omit ( customVars , 'merge-mode' ) ; } else { defaultVars = loadYamlFile ( defaultsPath ) ; result = _ . merge ( defaultVars , customVars ) ; } // Store variables in cached theme var _ . set ( theme , props . join ( '.' ) , result ) ; return result ; }


Input: Retrieves theme variables from cached theme var or from file if need be [CODESPLIT] function luiTheme ( props ) { var propsS = ( _ . isArray ( props ) ) ? props . join ( '.' ) : props , propsA = ( _ . isString ( props ) ) ? props . split ( '.' ) : props , objectVars , objectPath = [ ] ; objectVars = _ . result ( theme , propsS ) ; // If object is already cached in theme, return it if ( objectVars ) { return objectVars ; // Else load it from file } else { // Find the object fromp build file _ . each ( propsA , function ( prop ) { if ( _ . result ( build , _ . union ( objectPath , [ prop ] ) . join ( '.' ) ) || ( _ . includes ( _ . result ( build , objectPath . join ( '.' ) ) , prop ) ) ) { objectPath . push ( prop ) ; } else { return objectPath ; } } ) ; loadTheme ( objectPath ) ; return _ . result ( theme , propsS ) ; } }


Input: Writes a string in a file . [CODESPLIT] function write ( destination , data , callback ) { // Create directories if needs be mkdirp ( path . dirname ( destination ) , null , ( err , made ) => { if ( err ) { console . error ( err ) ; } else { fs . writeFile ( destination , data , ( err ) => { if ( err ) { console . error ( err ) ; } if ( typeof ( callback ) == 'function' ) { callback ( destination , data ) ; } } ) ; } } ) ; return destination ; }


Input: Initializes global variables . In particular merges defaults and custom options . [CODESPLIT] function init ( _options ) { // Build global options var options = _ . merge ( defaults , _options ) ; // Store paths base = options . base ; custom = options . custom ; // Retrieve build definition build = options . build = ( typeof options . build === 'object' ) ? options . build : require ( options . build ) ; // Create YAML schema (create custom types) yamlSchema = createYamlSchema ( options . customTypes ) ; return options ; }


Input: Compiles build definitions and theme variables into a ready - to - import scss string . [CODESPLIT] function redact ( _options , callback ) { var imports = [ ] , // List of scss to import output = '' , // The scss output errors = [ ] ; // List of errors encountered // Build core theme [ 'core' ] = { } ; _ . each ( _options . build . core , function ( objects , family ) { theme [ 'core' ] [ family ] = { } ; _ . each ( objects , function ( objectName ) { luiTheme ( 'core.' + family + '.' + objectName ) ; imports . push ( 'core/' + family + '/' + objectName ) ; } ) ; } ) ; // Build plugins if ( _options . build . plugins ) { theme [ 'plugins' ] = { } ; _ . each ( _options . build . plugins , function ( plugin ) { luiTheme ( 'plugins.' + plugin ) ; } ) ; } output = tosass . format ( { theme : theme , imports : imports } ) ; if ( typeof ( callback ) === 'function' ) { callback ( output ) ; } return output ; }


Input: Builds the scss and writes it into destination file passed in options . [CODESPLIT] function ( _options , callback ) { var options = init ( _options ) ; return write ( options . dest , redact ( options ) , callback ) ; }


Input: Converts objects to a map typed scss variable [CODESPLIT] function ( map ) { return '(' + Object . keys ( map ) . map ( function ( key ) { return key + ': ' + parseValue ( map [ key ] ) ; } ) . join ( ',' ) + ')' ; }


Input: Parses a Javascript Object and returns a sass map string [CODESPLIT] function objectToSass ( object ) { return Object . keys ( object ) . map ( function ( key ) { return '$' + key + ': ' + parseValue ( object [ key ] ) + ';' ; } ) . join ( '\n' ) ; }


Input: Distinguishes between strings list and maps and calls the appropriate parser [CODESPLIT] function parseValue ( value ) { if ( _ . isArray ( value ) ) return converters . list ( value ) ; else if ( _ . isPlainObject ( value ) ) return converters . map ( value ) ; else return value ; }


Input: Formats data into a string that can be evaluated as Scss / Sass [CODESPLIT] function formatData ( data ) { var result = '// ===================================\n' + '// =============== CORE ==============\n' + '// ===================================\n' + '@import "core/core";\n\n' + '// ===================================\n' + '// ========= THEME VARIABLES =========\n' + '// ===================================\n' + objectToSass ( { theme : data . theme } ) + '\n\n' + '// ===================================\n' + '// ============= OBJECTS =============\n' + '// ===================================\n' + '@import "' + data . imports . join ( '",\n        "' ) + '";' ; return result ; }


Input: NORMAL RANDOM VARIATES // FUNCTION : random ( [ dims ] [ opts ] ) Creates a matrix or array filled with normal random numbers . [CODESPLIT] function random ( dims , options ) { var opts = { } ; var isArray ; var ndims ; var err ; var len ; var mu ; var sigma ; var rand ; var dt ; if ( arguments . length > 0 ) { isArray = isPositiveIntegerArray ( dims ) ; if ( ! isArray && ! isPositiveInteger ( dims ) ) { throw new TypeError ( 'invalid input argument. Dimensions argument must be either a positive integer or a positive integer array. Value: `' + dims + '`.' ) ; } } if ( arguments . length > 1 ) { err = validate ( opts , options ) ; if ( err ) { throw err ; } } if ( opts . seed ) { rand = lcg ( opts . seed ) ; } else { rand = RAND ; } dt = opts . dtype || 'generic' ; mu = typeof opts . mu !== 'undefined' ? opts . mu : 0 ; sigma = typeof opts . sigma !== 'undefined' ? opts . sigma : 1 ; if ( arguments . length === 0 ) { return number ( mu , sigma , rand ) ; } if ( isArray ) { ndims = dims . length ; if ( ndims < 2 ) { len = dims [ 0 ] ; } } else { ndims = 1 ; len = dims ; } // 1-dimensional data structures... if ( ndims === 1 ) { if ( len === 1 ) { return number ( mu , sigma , rand ) ; } if ( dt === 'generic' ) { return array ( len , mu , sigma , rand ) ; } return typedarray ( len , dt , mu , sigma , rand ) ; } // Multidimensional data structures... if ( dt !== 'generic' ) { if ( ndims === 2 ) { return matrix ( dims , dt , mu , sigma , rand ) ; } // TODO: dstructs-ndarray support goes here. Until then, fall through to plain arrays... } return arrayarray ( dims , mu , sigma , rand ) ; }


Input: generate a guid that is tested unique against id s on the current doc [CODESPLIT] function domSafeRandomGuid ( ) { var _arguments = arguments ; var _again = true ; _function : while ( _again ) { numberOfBlocks = output = num = undefined ; var s4 = function s4 ( ) { return Math . floor ( ( 1 + Math . random ( ) ) * 65536 ) . toString ( 16 ) . substring ( 1 ) ; } ; _again = false ; var numberOfBlocks = _arguments [ 0 ] === undefined ? 4 : _arguments [ 0 ] ; var output = '' ; var num = numberOfBlocks ; while ( num > 0 ) { output += s4 ( ) ; if ( num > 1 ) output += '-' ; num -- ; } if ( null === document . getElementById ( output ) ) { return output ; } else { _arguments = [ numberOfBlocks ] ; _again = true ; continue _function ; } } }


Input: @class The ChainFunction wraps the functionality of a function executed on a chain context . [CODESPLIT] function ( options ) { options = Safe . object ( options ) ; this . name = Safe . string ( options . name , "?" ) ; this . fn = Safe . function ( options . fn , function ( ) { } ) ; this . args = Safe . array ( options . args ) ; }


Input: / * eslint - disable no - console [CODESPLIT] function I ( obj ) { function isObject ( v ) { return { } . toString . call ( v ) === '[object Object]' ; } function isArray ( v ) { return { } . toString . call ( v ) === '[object Array]' ; } function isFunc ( v ) { return { } . toString . call ( v ) === '[object Function]' ; } function assertA ( v , msg ) { if ( ! isArray ( v ) ) throw new Error ( msg ) ; } function assertAO ( v , msg ) { if ( ! isArray ( v ) && ! isObject ( v ) ) throw new Error ( msg ) ; } function _get ( o , p ) { var key = isFunc ( p [ 0 ] ) ? o . findIndex ( p [ 0 ] ) : p [ 0 ] ; return p . length ? _get ( o [ key ] , p . slice ( 1 ) ) : o ; } function _set ( o , p , v ) { var key = isFunc ( p [ 0 ] ) ? o . findIndex ( p [ 0 ] ) : p [ 0 ] ; // eslint-disable-next-line no-param-reassign if ( p . length === 1 ) o [ key ] = v ; else _set ( o [ key ] , p . slice ( 1 ) , v ) ; } function _copy ( o , path ) { var p = [ ] . concat ( toConsumableArray ( path ) ) ; var n = p . splice ( 0 , 1 ) [ 0 ] ; if ( isFunc ( n ) ) n = o . findIndex ( n ) ; if ( n !== undefined ) { if ( o [ n ] === undefined ) throw new Error ( 'Path not found' ) ; return isArray ( o ) ? [ ] . concat ( toConsumableArray ( o . slice ( 0 , n ) ) , [ _copy ( o [ n ] , p ) ] , toConsumableArray ( o . slice ( n + 1 ) ) ) : _extends ( { } , o , defineProperty ( { } , n , _copy ( o [ n ] , p ) ) ) ; } return isArray ( o ) ? [ ] . concat ( toConsumableArray ( o ) ) : _extends ( { } , o ) ; } function _diff ( a , b ) { var path = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : [ ] ; var acc = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : 0 ; function log ( p , msg , value ) { acc . push ( value ? { path : p , msg : msg , value : value } : { path : p , msg : msg } ) ; } function strPath ( p , key ) { var p2 = key !== undefined ? [ ] . concat ( toConsumableArray ( p ) , [ key ] ) : p ; return p2 . length ? p2 . join ( '.' ) : '(root)' ; } if ( isArray ( a ) && isArray ( b ) ) { if ( a !== b ) log ( strPath ( path ) , 'different reference' ) ; var deletions = { } ; b . forEach ( function ( v , k ) { if ( a . indexOf ( v ) === - 1 ) deletions [ k ] = v ; } ) ; a . forEach ( function ( v , k ) { var bk = b . indexOf ( v ) ; if ( bk === - 1 ) { if ( deletions [ k ] !== undefined ) { log ( strPath ( path , k ) , 'replace' , v ) ; delete deletions [ k ] ; } else { log ( strPath ( path , k ) , 'add' , v ) ; } } else if ( bk !== k && ! Object . keys ( deletions ) ) log ( strPath ( path , k ) , 'index changed from ' + bk , v ) ; } ) ; Object . keys ( deletions ) . forEach ( function ( k ) { return log ( strPath ( path , k ) , 'delete' ) ; } ) ; } else if ( isObject ( a ) && isObject ( b ) ) { if ( a !== b ) log ( strPath ( path ) , 'different reference' ) ; Object . keys ( b ) . forEach ( function ( k ) { if ( a [ k ] === undefined ) log ( strPath ( path , k ) , 'delete' , b [ k ] ) ; } ) ; Object . keys ( a ) . forEach ( function ( k ) { if ( b [ k ] === undefined ) log ( strPath ( path , k ) , 'add' , a [ k ] ) ; else if ( a [ k ] !== b [ k ] ) _diff ( a [ k ] , b [ k ] , path . concat ( [ k ] ) , acc ) ; } ) ; } else if ( ( typeof a === 'undefined' ? 'undefined' : _typeof ( a ) ) === 'object' || ( typeof b === 'undefined' ? 'undefined' : _typeof ( b ) ) === 'object' ) log ( strPath ( path ) , 'different types!' ) ; else if ( a !== b ) log ( strPath ( path ) , 'change' , a ) ; } assertAO ( obj , 'obj must be an object or array' ) ; return { result : obj , get : function get$$1 ( path ) { assertA ( path , 'path must be an array' ) ; return _get ( this . result , path ) ; } , set : function set$$1 ( value , path ) { assertA ( path , 'path must be an array' ) ; if ( this . copy ( path . slice ( 0 , path . length - 1 ) ) ) { _set ( this . result , path , value ) ; } return this ; } , push : function push ( value ) { var path = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : [ ] ; assertA ( path , 'path must be an array' ) ; if ( this . copy ( path ) ) { if ( path . length ) _set ( this . result , path , [ ] . concat ( toConsumableArray ( _get ( this . result , path ) ) , [ value ] ) ) ; else this . result . push ( value ) ; } return this ; } , delete : function _delete ( path ) { assertA ( path , 'path must be an array' ) ; var parentPath = path . slice ( 0 , path . length - 1 ) ; var last = path . slice ( path . length - 1 , path . length ) [ 0 ] ; if ( this . copy ( parentPath ) ) { var o = parentPath . length ? _get ( this . result , parentPath ) : this . result ; if ( isArray ( o ) ) { if ( isFunc ( last ) ) last = o . findIndex ( last ) ; if ( parentPath . length ) { _set ( this . result , parentPath , [ ] . concat ( toConsumableArray ( o . slice ( 0 , last ) ) , toConsumableArray ( o . slice ( last + 1 ) ) ) ) ; } else this . result = [ ] . concat ( toConsumableArray ( o . slice ( 0 , last ) ) , toConsumableArray ( o . slice ( last + 1 ) ) ) ; } else delete o [ last ] ; } return this ; } , copy : function copy ( path ) { assertA ( path , 'path must be an array' ) ; try { this . result = _copy ( this . result , path ) ; } catch ( e ) { console . warn ( e ) ; return false ; } return this ; } , diff : function diff ( other ) { var acc = [ ] ; _diff ( this . result , other , [ ] , acc ) ; return acc ; } } ; }


Input: VALIDATE // FUNCTION : validate ( opts options ) Validates function options . [CODESPLIT] function validate ( opts , options ) { if ( ! isObject ( options ) ) { return new TypeError ( 'invalid input argument. Options argument must be an object. Value: `' + options + '`.' ) ; } if ( options . hasOwnProperty ( 'mu' ) ) { opts . mu = options . mu ; if ( ! isNumber ( opts . mu ) ) { return new TypeError ( 'invalid option. `mu` parameter must be a number primitive. Option: `' + opts . mu + '`.' ) ; } } if ( options . hasOwnProperty ( 'sigma' ) ) { opts . sigma = options . sigma ; if ( ! isNonNegative ( opts . sigma ) ) { return new TypeError ( 'invalid option. `sigma` parameter must be a non-negative number. Option: `' + opts . sigma + '`.' ) ; } } if ( options . hasOwnProperty ( 'dtype' ) ) { opts . dtype = options . dtype ; if ( ! isString ( opts . dtype ) ) { return new TypeError ( 'invalid option. Data type option must be a string primitive. Option: `' + opts . dtype + '`.' ) ; } } if ( options . hasOwnProperty ( 'seed' ) ) { opts . seed = options . seed ; if ( ! isPositiveInteger ( opts . seed ) ) { return new TypeError ( 'invalid option. Seed option must be a positive integer. Option: `' + opts . seed + '`.' ) ; } } return null ; }


Input: Object to yaml string formatter [CODESPLIT] function objectProperty ( obj , indentLength = 1 , inArray = 0 ) { if ( Object . keys ( obj ) . length === 0 ) { return ' {}' ; } let str = '\n' ; const objectPrefix = getPrefix ( indentLength , indentChars ) ; Object . keys ( obj ) . forEach ( ( name ) => { const value = obj [ name ] ; const type = typeOf ( value ) ; const inArrayPrefix = getPrefix ( inArray , '  ' ) ; const afterPropsIndent = NO_INDENT_TYPES . includes ( type ) ? '' : ' ' ; const valueString = checkCircular ( value ) ? ' [Circular]' : typifiedString ( type , value , indentLength + 1 , inArray ) ; str += ` ${ inArrayPrefix } ${ objectPrefix } ${ name } ${ afterPropsIndent } ${ valueString } \n ` ; } ) ; return str . substring ( 0 , str . length - 1 ) ; }


Input: Array to yaml string formatter [CODESPLIT] function arrayProperty ( values , indentLength = 1 , inArray = 0 ) { if ( values . length === 0 ) { return ' []' ; } let str = '\n' ; const arrayPrefix = getPrefix ( indentLength , indentChars ) ; values . forEach ( ( value ) => { const type = typeOf ( value ) ; const inArrayPrefix = getPrefix ( inArray , '  ' ) ; const valueString = checkCircular ( value ) ? '[Circular]' : typifiedString ( type , value , indentLength , inArray + 1 ) . toString ( ) . trimLeft ( ) ; str += ` ${ inArrayPrefix } ${ arrayPrefix } ${ valueString } \n ` ; } ) ; return str . substring ( 0 , str . length - 1 ) ; }


Input: temp solution until https : // github . com / iarna / in - publish / issues / 8 gets fixed . [CODESPLIT] function inCommand ( cmd ) { let npm_config_argv , V ; try { npm_config_argv = JSON . parse ( process . env [ 'npm_config_argv' ] ) ; } catch ( e ) { return false ; } if ( typeof npm_config_argv !== 'object' ) { process . exit ( 1 ) ; } if ( ! npm_config_argv . cooked ) { process . exit ( 1 ) ; } if ( ! npm_config_argv . cooked instanceof Array ) { process . exit ( 1 ) ; } while ( ( V = npm_config_argv . cooked . shift ( ) ) !== undefined ) { if ( cmd . test ( V ) ) { return true ; } } return false ; }


Input: Tests [CODESPLIT] function mochaTask ( reporter ) { return function ( ) { return gulp . src ( paths . test ) . pipe ( $ . mocha ( { reporter : reporter || "spec" } ) ) ; } ; }


Input: RANDOM // FUNCTION : random ( dims mu sigma [ rand ] ) Creates a multidimensional array of normally distributed random numbers . [CODESPLIT] function random ( dims , mu , sigma , rand ) { var draw = partial ( mu , sigma , rand ) ; return recurse ( dims , 0 , draw ) ; }


Input: RANDOM // FUNCTION : random ( len dt mu sigma [ rand ] ) Creates a typed array of normally distributed random numbers . [CODESPLIT] function random ( len , dt , mu , sigma , rand ) { /* jshint newcap:false */ var ctor ; var out ; var draw ; var i ; draw = partial ( mu , sigma , rand ) ; ctor = ctors ( dt ) ; if ( ctor === null ) { throw new Error ( 'invalid value. Data type does not have a corresponding array constructor. Value: `' + dt + '`.' ) ; } out = new ctor ( len ) ; for ( i = 0 ; i < len ; i ++ ) { out [ i ] = draw ( ) ; } return out ; }


Input: TODO refactor this terribleness [CODESPLIT] function parseJson ( inputText ) { // sizeOf (/nEvents/n) is 10 var text = inputText . substring ( inputText . indexOf ( "\\nEvents\\n" ) + 10 , inputText . indexOf ( "\\n\\n\\nBirths" ) ) , retArr = [ ] , retString = "" , endIndex , startIndex = 0 ; if ( text . length == 0 ) { return retArr ; } while ( true ) { endIndex = text . indexOf ( "\\n" , startIndex + delimiterSize ) ; var eventText = ( endIndex == - 1 ? text . substring ( startIndex ) : text . substring ( startIndex , endIndex ) ) ; // replace dashes returned in text from Wikipedia's API eventText = eventText . replace ( / \\u2013\s* / g , '' ) ; // add comma after year so Alexa pauses before continuing with the sentence eventText = eventText . replace ( / (^\d+) / , '$1,' ) ; eventText = 'In ' + eventText ; startIndex = endIndex + delimiterSize ; retArr . push ( eventText ) ; if ( endIndex == - 1 ) { break ; } } if ( retString != "" ) { retArr . push ( retString ) ; } retArr . reverse ( ) ; return retArr ; }


Input: @param { String } quantifier [CODESPLIT] function getRangeData ( quantifier ) { let rangeType = dateRange . DAY ; let startRange = 'day' ; if ( / seconds? / i . test ( quantifier ) ) { rangeType = dateRange . SEC ; startRange = 'second' ; } else if ( / minutes? / i . test ( quantifier ) ) { rangeType = dateRange . MIN ; startRange = 'minute' ; } else if ( / hours? / i . test ( quantifier ) ) { rangeType = dateRange . HOUR ; startRange = 'hour' ; } else if ( new RegExp ( ` ${ days . join ( 's?|' ) } ` , 'i' ) . test ( quantifier ) ) { rangeType = dateRange . DAY * 7 ; startRange = quantifier ; } return { rangeType : rangeType , startRange : startRange } ; }


Input: Manages all communication with a Kubernetes resource endpoint ( i . e . pods ) [CODESPLIT] function ResourceClient ( opts ) { opts = opts || { } this . name = opts . name this . token = opts . token this . baseUrl = opts . baseUrl }


Input: Backend response . [CODESPLIT] function RESTResponse ( url , method , body ) { /** The original request. */ this . request = { url : url , method : method } ; /** The body of the response. */ this . body = body || "" ; /** Status of the response. */ this . status = "200" ; }


Input: polyfilled Maps with es6 - shim might exist without for .. of [CODESPLIT] function ( map , receive ) { var entries = mapEntries . call ( map ) ; var next ; do { next = entries . next ( ) ; } while ( ! next . done && receive ( next . value ) ) ; }


Input: NORMAL TAIL // FUNCTION dRanNormalTail ( dMin iNegative rand ) Transform the tail of the normal distribution to the unit interval and then use rejection technique to generate standar normal variable . Reference : Marsaclia G . ( 1964 ) . Generating a Variable from the Tail of the Normal Distribution . Technometrics 6 ( 1 ) 101–102 . doi : 10 . 1080 / 00401706 . 1964 . 10490150 [CODESPLIT] function dRanNormalTail ( dMin , iNegative , rand ) { var x , y ; do { x = ln ( rand ( ) ) / dMin ; y = ln ( rand ( ) ) ; } while ( - 2 * y < x * x ) ; return iNegative ? x - dMin : dMin - x ; }


Input: Decorator which validates an options hash and delegates to func . If the options are not an object a TypeError is thrown . If the options hash is missing any of the required properties a RangeError is thrown . [CODESPLIT] function reqo ( func , requiredKeys , optionsIndex = 0 , context = undefined ) { return function ( ... args ) { const options = args [ optionsIndex ] ; if ( ! isPlainObject ( options ) ) { throw new TypeError ( 'options must be a plain object literal' ) ; } // Check that all of the properties represented in requiredKeys are present // as properties in the options hash. Does so by taking an intersection // of the options keys and the required keys, and then checking the // intersection is equivalent to the requirements. const optionsKeys = keys ( options ) ; const intersectionOfKeys = intersection ( requiredKeys , optionsKeys ) ; const hasAllRequiredKeys = isEqual ( intersectionOfKeys , requiredKeys ) ; // If any required keys are missing in options hash. if ( ! hasAllRequiredKeys ) { const missingOptions = difference ( requiredKeys , intersectionOfKeys ) ; throw new RangeError ( 'Options must contain ' + missingOptions . toString ( ) ) ; } // Call the decorated function in the right context with its' arguments. const boundFunc = func . bind ( context ) ; return boundFunc ( ... args ) ; } ; }


Input: Registers an item to be managed . [CODESPLIT] function ( component ) { var id = component . getId ( ) ; // <debug> if ( this . map [ id ] ) { Ext . Logger . warn ( 'Registering a component with a id (`' + id + '`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`.' ) ; } // </debug> this . map [ component . getId ( ) ] = component ; }


Input: Creates a new Component from the specified config object using the config object s xtype to determine the class to instantiate . [CODESPLIT] function ( component , defaultType ) { if ( component . isComponent ) { return component ; } else if ( Ext . isString ( component ) ) { return Ext . createByAlias ( 'widget.' + component ) ; } else { var type = component . xtype || defaultType ; return Ext . createByAlias ( 'widget.' + type , component ) ; } }


Input: runs a name . space [CODESPLIT] function rns ( ) { let jargv = _ . $ ( 'env.jargv' ) let key = _ . get ( jargv , '_[0]' ) let prop = key ? _ . get ( snapptop , key ) : null if ( ! _ . isFunction ( prop ) ) return _ . log ( ` \n ${ key || 'NO KEY' } \n ` ) _ . log ( ` \n ${ key } \n ` ) _ . log ( jargv ) _ . log ( ) jargv = _ . omit ( jargv , [ '_' ] ) var ret = _ . attempt ( prop , jargv , ( err , result ) => { if ( err ) return _ . log ( err ) _ . log ( result ) } ) if ( _ . isError ( ret ) ) _ . log ( ret ) return ret }


Input: Retrieves Ext . dom . Element objects . { @link Ext#get } is alias for { @link Ext . dom . Element#get } . [CODESPLIT] function ( element ) { var cache = this . cache , instance , dom , id ; if ( ! element ) { return null ; } // DOM Id if ( typeof element == 'string' ) { dom = document . getElementById ( element ) ; if ( cache . hasOwnProperty ( element ) ) { instance = cache [ element ] ; } // Is this in the DOM proper if ( dom ) { // Update our Ext Element dom reference with the true DOM (it may have changed) if ( instance ) { instance . dom = dom ; } else { // Create a new instance of Ext Element instance = cache [ element ] = new this ( dom ) ; } } // Not in the DOM, but if its in the cache, we can still use that as a DOM fragment reference, otherwise null else if ( ! instance ) { instance = null ; } return instance ; } // DOM element if ( 'tagName' in element ) { id = element . id ; if ( cache . hasOwnProperty ( id ) ) { instance = cache [ id ] ; instance . dom = element ; return instance ; } else { instance = new this ( element ) ; cache [ instance . getId ( ) ] = instance ; } return instance ; } // Ext Element if ( element . isElement ) { return element ; } // Ext Composite Element if ( element . isComposite ) { return element ; } // Array passed if ( Ext . isArray ( element ) ) { return this . select ( element ) ; } // DOM Document if ( element === document ) { // create a bogus element object representing the document object if ( ! this . documentElement ) { this . documentElement = new this ( document . documentElement ) ; this . documentElement . setId ( 'ext-application' ) ; } return this . documentElement ; } return null ; }


Input: Serializes a DOM element and its children recursively into a string . [CODESPLIT] function ( node ) { var result = '' , i , n , attr , child ; if ( node . nodeType === document . TEXT_NODE ) { return node . nodeValue ; } result += '<' + node . nodeName ; if ( node . attributes . length ) { for ( i = 0 , n = node . attributes . length ; i < n ; i ++ ) { attr = node . attributes [ i ] ; result += ' ' + attr . name + '="' + attr . value + '"' ; } } result += '>' ; if ( node . childNodes && node . childNodes . length ) { for ( i = 0 , n = node . childNodes . length ; i < n ; i ++ ) { child = node . childNodes [ i ] ; result += this . serializeNode ( child ) ; } } result += '</' + node . nodeName + '>' ; return result ; }


Input:
@event painted Fires whenever this Element actually becomes visible ( painted ) on the screen . This is useful when you need to perform read operations on the DOM element i . e : calculating natural sizes and positioning . [CODESPLIT] function ( dom ) { if ( typeof dom == 'string' ) { dom = document . getElementById ( dom ) ; } if ( ! dom ) { throw new Error ( "Invalid domNode reference or an id of an existing domNode: " + dom ) ; } /**
         * The DOM element
         * @property dom
         * @type HTMLElement
         */ this . dom = dom ; this . getUniqueId ( ) ; }


Input: Sets the passed attributes as attributes of this element ( a style attribute can be a string object or function ) . [CODESPLIT] function ( attributes , useSet ) { var dom = this . dom , attribute , value ; for ( attribute in attributes ) { if ( attributes . hasOwnProperty ( attribute ) ) { value = attributes [ attribute ] ; if ( attribute == 'style' ) { this . applyStyles ( value ) ; } else if ( attribute == 'cls' ) { dom . className = value ; } else if ( useSet !== false ) { if ( value === undefined ) { dom . removeAttribute ( attribute ) ; } else { dom . setAttribute ( attribute , value ) ; } } else { dom [ attribute ] = value ; } } } return this ; }


Input: Returns the value of an attribute from the element s underlying DOM node . [CODESPLIT] function ( name , namespace ) { var dom = this . dom ; return dom . getAttributeNS ( namespace , name ) || dom . getAttribute ( namespace + ":" + name ) || dom . getAttribute ( name ) || dom [ name ] ; }


Input: Removes this element s DOM reference . Note that event and cache removal is handled at { [CODESPLIT] function ( ) { this . isDestroyed = true ; var cache = Ext . Element . cache , dom = this . dom ; if ( dom && dom . parentNode && dom . tagName != 'BODY' ) { dom . parentNode . removeChild ( dom ) ; } delete cache [ this . id ] ; delete this . dom ; }


Input: Gets the globally shared flyweight Element with the passed node as the active element . Do not store a reference to this element - the dom node can be overwritten by other code . { @link Ext#fly } is alias for { @link Ext . dom . Element#fly } . [CODESPLIT] function ( element , named ) { var fly = null , flyweights = Element . _flyweights , cachedElement ; named = named || '_global' ; element = Ext . getDom ( element ) ; if ( element ) { fly = flyweights [ named ] || ( flyweights [ named ] = new Element . Fly ( ) ) ; fly . dom = element ; fly . isSynchronized = false ; cachedElement = Ext . cache [ element . id ] ; if ( cachedElement && cachedElement . isElement ) { cachedElement . isSynchronized = false ; } } return fly ; }


Input: A client - side router for stateful - controller using the history API @module stateful - controller - browser - router @author Joris van der Wel <joris@jorisvanderwel . com > Construct a new router [CODESPLIT] function Router ( window , urlStateMap , frontController ) { EventEmitter . call ( this ) ; this . window = window ; this . urlStateMap = urlStateMap ; this . frontController = frontController ; this . currentStateList = null ; this . _pendingTransitionPromise = null ; this . _pendingReplace = null ; this . _initialHistoryState = null ; this . _queue = { hasEntry : false , stateList : null , fromHistory : false , upgrade : false , push : false , promise : null , resolve : null , reject : null } ; if ( ! window || ! urlStateMap || ! frontController ) { throw Error ( 'Missing argument' ) ; } if ( typeof this . urlStateMap . toURL !== 'function' || typeof this . urlStateMap . fromURL !== 'function' ) { throw Error ( 'Argument `urlStateMap` must implement toURL(states) and fromURL(url)' ) ; } if ( ! Router . isSupported ( this . window ) ) { throw Error ( 'Argument `window` does not support the history API' ) ; } if ( this . frontController . isStatefulController1 !== true ) { throw Error ( 'Argument `frontController` is not a stateful-controller' ) ; } this . _onpopstate = this . _onpopstate . bind ( this ) ; }


Input: Sorts the data in the Store by one or more of its properties . Example usage : [CODESPLIT] function ( sorters , direction , where , doSort ) { var me = this , sorter , sorterFn , newSorters ; if ( Ext . isArray ( sorters ) ) { doSort = where ; where = direction ; newSorters = sorters ; } else if ( Ext . isObject ( sorters ) ) { doSort = where ; where = direction ; newSorters = [ sorters ] ; } else if ( Ext . isString ( sorters ) ) { sorter = me . sorters . get ( sorters ) ; if ( ! sorter ) { sorter = { property : sorters , direction : direction } ; newSorters = [ sorter ] ; } else if ( direction === undefined ) { sorter . toggle ( ) ; } else { sorter . setDirection ( direction ) ; } } if ( newSorters && newSorters . length ) { newSorters = me . decodeSorters ( newSorters ) ; if ( Ext . isString ( where ) ) { if ( where === 'prepend' ) { sorters = me . sorters . clone ( ) . items ; me . sorters . clear ( ) ; me . sorters . addAll ( newSorters ) ; me . sorters . addAll ( sorters ) ; } else { me . sorters . addAll ( newSorters ) ; } } else { me . sorters . clear ( ) ; me . sorters . addAll ( newSorters ) ; } if ( doSort !== false ) { me . onBeforeSort ( newSorters ) ; } } if ( doSort !== false ) { sorters = me . sorters . items ; if ( sorters . length ) { //construct an amalgamated sorter function which combines all of the Sorters passed sorterFn = function ( r1 , r2 ) { var result = sorters [ 0 ] . sort ( r1 , r2 ) , length = sorters . length , i ; //if we have more than one sorter, OR any additional sorter functions together for ( i = 1 ; i < length ; i ++ ) { result = result || sorters [ i ] . sort . call ( this , r1 , r2 ) ; } return result ; } ; me . doSort ( sorterFn ) ; } } return sorters ; }


Input: plugins = { exportHead : func exportEnd : func exportTypedef : func exportEnum : func exportStruct : func exportStatic : func getExportFile : func } callback ( isok errinfo ) [CODESPLIT] function exportCode ( projname , root , plugins , objname , callback , option ) { if ( option == undefined ) { option = { isclient : false , mainobj : objname , projname : projname } ; } else { if ( ! option . hasOwnProperty ( 'isclient' ) ) { option . isclient = false ; } option . mainobj = objname ; option . projname = projname ; } var lstexport = [ ] ; var obj = base . getGlobalObj ( objname , root ) ; if ( obj != undefined ) { lstexport = addExportObj ( obj , root , lstexport , option ) ; } procStaticTable ( objname , root , option ) ; if ( plugins != undefined ) { if ( ! fs . existsSync ( projname ) ) { fs . mkdirSync ( projname ) ; } var curparams = { projname_up : projname . toUpperCase ( ) , projname : projname } ; //------------------------------------------------------------------------------------ // typedef curparams . block_typedef = [ ] ; var typedefarr = undefined ; for ( var i = 0 ; i < lstexport . length ; ++ i ) { var obj = base . getGlobalObj ( lstexport [ i ] , root ) ; if ( obj != undefined ) { if ( obj . type == 'type' ) { var cs = plugins . exportTypedef ( obj , root , callback , option ) ; if ( cs != undefined ) { if ( typedefarr == undefined ) { typedefarr = [ ] ; for ( var ai = 0 ; ai < cs . length ; ++ ai ) { typedefarr . push ( [ ] ) ; } } for ( var ai = 0 ; ai < cs . length ; ++ ai ) { typedefarr [ ai ] . push ( cs [ ai ] ) ; } } } } } if ( typedefarr != undefined ) { curparams . block_typedef = alignCodeEx ( typedefarr , '' ) ; } //------------------------------------------------------------------------------------ // enum curparams . block_enum = [ ] ; for ( var i = 0 ; i < lstexport . length ; ++ i ) { var obj = base . getGlobalObj ( lstexport [ i ] , root ) ; if ( obj != undefined ) { if ( obj . type == 'enum' ) { var enumobj = plugins . exportEnum ( obj , root , callback , option ) ; if ( enumobj != undefined ) { curparams . block_enum . push ( enumobj ) ; } } } } //------------------------------------------------------------------------------------ // struct curparams . block_struct = [ ] ; curparams . csvloader = [ ] ; for ( var i = 0 ; i < lstexport . length ; ++ i ) { var obj = base . getGlobalObj ( lstexport [ i ] , root ) ; if ( obj != undefined ) { if ( obj . name == objname ) { var mainobj = plugins . exportMainObj ( obj , root , callback , option ) ; if ( mainobj != undefined ) { curparams . mainobj = mainobj ; } base . forEachStruct ( obj . name , obj , root , function ( structname , cobj , root ) { if ( option . isclient ) { if ( cobj . name . name . indexOf ( '_' ) == 0 ) { return ; } } if ( base . isStatic ( cobj . type , root ) ) { var csvloader = plugins . exportCSVLoader ( cobj , root , callback , option ) ; if ( csvloader != undefined ) { curparams . csvloader . push ( csvloader ) ; } } } ) ; } else if ( obj . type == 'struct' ) { var structobj = plugins . exportStruct ( obj , root , callback , option ) ; if ( structobj != undefined ) { curparams . block_struct . push ( structobj ) ; } } else if ( obj . type == 'static' ) { var structobj = plugins . exportStatic ( obj , root , callback , option ) ; if ( structobj != undefined ) { curparams . block_struct . push ( structobj ) ; } } } } //------------------------------------------------------------------------------------ // message curparams . block_sendmsg = [ ] ; curparams . block_onmsg = [ ] ; for ( var i = 0 ; i < root . length ; ++ i ) { if ( root [ i ] . type == 'message' ) { if ( base . isReqMsg ( root [ i ] . name ) ) { var co = plugins . exportSendMsg ( root [ i ] , root , callback , option ) ; curparams . block_sendmsg . push ( co ) ; } else if ( base . isResMsg ( root [ i ] . name ) ) { var co = plugins . exportOnMsg ( root [ i ] , root , callback , option ) ; curparams . block_onmsg . push ( co ) ; } } } //------------------------------------------------------------------------------------ // template var tmpfilename = plugins . getTemplate ( projname , option ) ; var tmpbuf = fs . readFileSync ( path . join ( __dirname , 'plugins' , tmpfilename ) , 'utf-8' ) ; var tmphb = handlebars . compile ( tmpbuf ) ; tmpbuf = tmphb ( curparams ) ; tmpbuf = replaceStr ( tmpbuf ) ; var tmparr = JSON . parse ( tmpbuf ) ; if ( tmparr != undefined ) { for ( var ti = 0 ; ti < tmparr . length ; ++ ti ) { var curtmpbuf = fs . readFileSync ( path . join ( __dirname , 'plugins' , tmparr [ ti ] . srcfile ) , 'utf-8' ) ; var curtemplate = handlebars . compile ( curtmpbuf ) ; var strbuf = curtemplate ( curparams ) ; strbuf = replaceStr ( strbuf ) ; fs . writeFileSync ( projname + '/' + tmparr [ ti ] . filename , strbuf , 'utf-8' ) ; } } return tmparr ; } return undefined ; }


Input: An eventual schema exists for a key - value object . [CODESPLIT] function ( rules ) { this . _instantiatedDate = new Date ( ) ; this . _instanceCount = 0 ; this . _propertyCount = 0 ; this . _collatedInstances = null ; this . _rules = ( rules && this . _checkRules ( rules ) ) || [ ] ; this . initEventualSchema ( ) ; }