Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process: use rest parameters in nextTick. #12183

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions lib/internal/process/next_tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,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;
Copy link
Member

@lpinca lpinca Apr 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a minor difference now when arguments.length === 1 as args is an empty array instead of undefined. I don't know if it's relevant. If not LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed the use site. It doesn't seem to affect performance though.

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,
Expand Down