events: fix potential permanent deopt
PR-URL: https://github.com/nodejs/node/pull/13384 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
8cc8358ef7
commit
e374e44a8a
@ -306,10 +306,25 @@ EventEmitter.prototype.prependListener =
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onceWrapper() {
|
function onceWrapper() {
|
||||||
this.target.removeListener(this.type, this.wrapFn);
|
|
||||||
if (!this.fired) {
|
if (!this.fired) {
|
||||||
|
this.target.removeListener(this.type, this.wrapFn);
|
||||||
this.fired = true;
|
this.fired = true;
|
||||||
this.listener.apply(this.target, arguments);
|
switch (arguments.length) {
|
||||||
|
case 0:
|
||||||
|
return this.listener.call(this.target);
|
||||||
|
case 1:
|
||||||
|
return this.listener.call(this.target, arguments[0]);
|
||||||
|
case 2:
|
||||||
|
return this.listener.call(this.target, arguments[0], arguments[1]);
|
||||||
|
case 3:
|
||||||
|
return this.listener.call(this.target, arguments[0], arguments[1],
|
||||||
|
arguments[2]);
|
||||||
|
default:
|
||||||
|
const args = new Array(arguments.length);
|
||||||
|
for (var i = 0; i < args.length; ++i)
|
||||||
|
args[i] = arguments[i];
|
||||||
|
this.listener.apply(this.target, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user