From 5bc1a5163d07e23d968c15ba37ff777a9d2fd5a5 Mon Sep 17 00:00:00 2001 From: prabirshrestha Date: Sat, 26 Jan 2013 01:02:16 -0500 Subject: [PATCH] nextTick with browser fallback --- lib/step.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/step.js b/lib/step.js index b524a6a..c775daa 100755 --- a/lib/step.js +++ b/lib/step.js @@ -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 () { @@ -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); + }; +} else { + Step.nextTick = process.nextTick; +} // Hook into commonJS module systems if (typeof module !== 'undefined' && "exports" in module) {