mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
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:
1 parent
48cad9cde6
commit
a666238ffe
1 file changed
+17
-2
+17
-2
@@ -306,10 +306,25 @@ EventEmitter.prototype.prependListener =
|
||||
};
|
||||
|
||||
function onceWrapper() {
|
||||
this.target.removeListener(this.type, this.wrapFn);
|
||||
if (!this.fired) {
|
||||
this.target.removeListener(this.type, this.wrapFn);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user