lib/Events.js
function waitFor (event, listener, context, wait) {
    var timeout;
    if (!wait) {
        throw new Error("[FATAL] waitFor called without wait time");
    }
    var handler = function () {
        clearTimeout(timeout);
        listener.apply(context, arguments);
    };
    timeout = setTimeout(function () {
        this.off(event, handler, context);
        listener.call(context, "timeout");
    }.bind(this), wait);
    this.once(event, handler, context);
}
function waitFor (event, listener, context, wait) {
    var timeout;
    if (!wait) {
        throw new Error("[FATAL] waitFor called without wait time");
    }
    var handler = function () {
        clearTimeout(timeout);
        listener.apply(context, arguments);
    };
    timeout = setTimeout(function () {
        this.off(event, handler, context);
        listener.call(context, "timeout");
    }.bind(this), wait);
    this.once(event, handler, context);
}
function waitFor ( event , listener , context , wait ) { var timeout ; if ( ! wait ) { throw new Error ( "[FATAL] waitFor called without wait time" ) ; } var handler = function ( ) { clearTimeout ( timeout ) ; listener . apply ( context , arguments ) ; } ; timeout = setTimeout ( function ( ) { this . off ( event , handler , context ) ; listener . call ( context , "timeout" ) ; } . bind ( this ) , wait ) ; this . once ( event , handler , context ) ; }
Waits for wait ms for event to fire or calls listener with error, removing listener
Waits for wait ms for event to fire or calls listener with error removing listener