diff --git a/lib/internal/process/next_tick.js b/lib/internal/process/next_tick.js index ad635aaf494b33..290888bf5b1b16 100644 --- a/lib/internal/process/next_tick.js +++ b/lib/internal/process/next_tick.js @@ -73,6 +73,9 @@ function setupNextTick() { callback(); } else { switch (args.length) { + case 0: + callback(); + break; case 1: callback(args[0]); break; @@ -137,20 +140,13 @@ function setupNextTick() { } while (tickInfo[kLength] !== 0); } - function nextTick(callback) { + function nextTick(callback, ...args) { if (typeof callback !== 'function') throw new TypeError('callback is not a function'); // on the way out, don't bother. it won't get fired anyway. if (process._exiting) return; - var args; - if (arguments.length > 1) { - args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) - args[i - 1] = arguments[i]; - } - nextTickQueue.push({ callback, domain: process.domain || null,