Permalink
Browse files

fallback to nextTick if setImmediate is not a function

  • Loading branch information...
1 parent 7f760fb commit c1de4d6a533cf6cfb8c275c8f4c65da8b03b0107 Jaakko Manninen committed Mar 12, 2013
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/ncp.js
View
@@ -43,9 +43,15 @@ function ncp (source, dest, options, callback) {
return getStats(source);
}
+ function defer(fn) {
+ if (typeof(setImmediate) === 'function')
+ return setImmediate(fn);
+ return process.nextTick(fn);
+ }
+
function getStats(source) {
if (running >= limit) {
- return setImmediate(function () {
+ return defer(function () {
getStats(source);
});
}

0 comments on commit c1de4d6

Please sign in to comment.