Skip to content

Commit

Permalink
improve emitter.once() performance
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Jan 8, 2020
1 parent 7ad7ba6 commit 0754cd5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions events.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ EventEmitter.prototype.prependListener =
};

function onceWrapper() {
var args = [];
for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);
if (!this.fired) {
this.target.removeListener(this.type, this.wrapFn);
this.fired = true;
return ReflectApply(this.listener, this.target, args);
if (arguments.length === 0)
return this.listener.call(this.target);
return this.listener.apply(this.target, arguments);
}
}

Expand Down

0 comments on commit 0754cd5

Please sign in to comment.