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
16 changes: 15 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,20 @@ Step.fn = function StepFn() {
}
}

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

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