nl_tokens: Start a watch interval when a file exists remove it from our files array . If the files array is empty call the listener and stop the watch interval .
pl_tokens: function start ( pollInterval , input , listener ) { var result = ( pollInterval > 0 && typeof listener === "function" && ( ! ! input ) ) ; if ( result ) { if ( this . isStarted ( ) ) { throw new Error ( "Notifier already started" ) ; } this . callback = listener ; this . interval = parseInt ( pollInterval , 10 ) ; // Poll the filesystem for the files to exist // Checks the child process expected output to determine success or failure // if the file exists, then it succeeded. this . watcher = setInterval ( this . csFactory ( function ( done ) { var self = this ; var eoi = typeof input . EOI === "function" && input . EOI ( ) ; if ( eoi ) { Promise . all ( Object . keys ( self . files ) . map ( function ( file ) { return pathExists ( file , { returnFile : true } ) ; } ) ) . then ( function ( files ) { var callback = self . callback ; try { files . forEach ( function ( file ) { file && self . _remove ( file , true ) ; } ) ; if ( self . _isDone ( ) ) { self . _closeWatcher ( ) ; if ( self . callback ) { self . callback = null ; setImmediate ( function ( ) { callback ( self . getError ( ) , <mask> . filesDone ) ; } ) ; } } } catch ( e ) { console . error ( e ) ; } done ( ) ; } ) ; } else { done ( ) ; } } . bind ( this ) , L_WAIT ) , this . interval ) ; } else { console . error ( "Bad poll interval, async listener, or input generator supplied" ) ; } return result ; }