Skip to content
Open
Changes from all commits
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
10 changes: 9 additions & 1 deletion lib/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function Step() {
localCallback(error, result);
}
}
process.nextTick(check); // Ensures that check is called at least once
Step.nextTick(check); // Ensures that check is called at least once

// Generates a callback for the group
return function () {
Expand Down Expand Up @@ -145,6 +145,14 @@ Step.fn = function StepFn() {
}
}

// nextTick with browser fallback
if (typeof process === 'undefined' || !(process.nextTick)) {
Step.nextTick = function (fn) {
setTimeout(fn, 0);
Copy link

Choose a reason for hiding this comment

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

I would not do this, as this is not merely equal to process.nextTick.
A setTimeout always takes at least 20ms, if you have a lot of small steps, this will slow down the code a lot.

};
} else {
Step.nextTick = process.nextTick;
}

// Hook into commonJS module systems
if (typeof module !== 'undefined' && "exports" in module) {
Expand Down