lib/events.js
function until(emitter, eventName, handler, context) {
  handler = context ? handler.bind(context) : handler;
  let wrapper = function untilHandler(event) {
    if (handler(event))
      emitter.removeEventListener(eventName, untilHandler);
  };
  emitter.addEventListener(eventName, wrapper);
  return wrapper;
}
function until(emitter, eventName, handler, context) {
  handler = context ? handler.bind(context) : handler;
  let wrapper = function untilHandler(event) {
    if (handler(event))
      emitter.removeEventListener(eventName, untilHandler);
  };
  emitter.addEventListener(eventName, wrapper);
  return wrapper;
}
function until ( emitter , eventName , handler , context ) { handler = context ? handler . bind ( context ) : handler ; let wrapper = function untilHandler ( event ) { if ( handler ( event ) ) emitter . removeEventListener ( eventName , untilHandler ) ; } ; emitter . addEventListener ( eventName , wrapper ) ; return wrapper ; }
Register to receive events until the handler function returns true.
Register to receive events until the handler function returns true .