nl_tokens: / * Read imports from a given file and return them
pl_tokens: function readImports ( file ) { return new Promise ( function ( resolve , reject ) { // read 60 chars at a time. roughly optimal: memory vs performance var stream = fs . createReadStream ( file , { encoding : 'utf8' , highWaterMark : 8 * 60 } ) ; var buffer = "" ; var parser = new Parser ( ) ; stream . on ( 'error' , function ( ) { // failed to process the file, so return null resolve ( null ) ; } ) ; stream . on ( 'data' , function ( chunk ) { <mask> += chunk ; // when the chunk has a newline, process each line if ( chunk . indexOf ( '\n' ) > - 1 ) { var lines = buffer . split ( '\n' ) ; lines . slice ( 0 , lines . length - 1 ) . forEach ( parser . parseLine . bind ( parser ) ) ; buffer = lines [ lines . length - 1 ] ; // end the stream early if we're past the imports // to save on memory if ( parser . isPastImports ( ) ) { stream . destroy ( ) ; } } } ) ; stream . on ( 'close' , function ( ) { resolve ( parser . getImports ( ) ) ; } ) ; } ) ; }