nl_tokens: -------------------------------- SPEC FILTERING --------------------------------
pl_tokens: function specFilter ( pattern , files ) { var specPattern , patternArray , filteredArray = [ ] , scriptSpecs = [ ] , matchPath = function ( path ) { return Boolean ( path . match ( specPattern ) ) ; } ; if ( pattern ) { // For '*' to work as a wildcard. pattern = pattern . split ( '*' ) . join ( '[\\S]*' ) . replace ( / \. / g , '\\.' ) ; // This allows for comma separated strings to which we can match the // spec files. patternArray = pattern . split ( ',' ) ; while ( patternArray . length > 0 ) { pattern = ( patternArray . splice ( 0 , 1 ) [ 0 ] ) ; if ( pattern . length > 0 ) { if ( pattern . indexOf ( '/' ) === - 1 ) { specPattern = new RegExp ( '(' + pattern + '[^/]*)(?!/)$' , 'ig' ) ; } else if ( pattern . indexOf ( '/' ) === 0 ) { specPattern = new RegExp ( '(' + pattern + '[^/]*)(?=/)' , 'ig' ) ; } else { throw <mask> Error ( '--filter flag seems to be in the wrong format.' ) ; } // push is usually faster than concat. [ ] . push . apply ( scriptSpecs , files . filter ( matchPath ) ) ; } } filteredArray = _ . uniq ( scriptSpecs ) ; } return filteredArray ; }