nl_tokens: Wait for the given EventEmitter to emit the given event . Optionally reject the promise if an error event occurs while waiting .
pl_tokens: function waitOn ( emitter , event , waitError ) { if ( waitError ) { return new Promise ( ( resolve , reject ) => { function unbind ( ) { emitter . removeListener ( 'error' , onError ) ; emitter . removeListener ( event , onEvent ) ; } function onEvent ( value ) { unbind ( ) ; resolve ( value ) ; } function onError ( err ) { unbind ( ) ; reject ( err ) ; } emitter . <mask> ( 'error' , onError ) ; emitter . on ( event , onEvent ) ; } ) ; } return new Promise ( ( resolve ) => emitter . once ( event , resolve ) ) ; }