Comparing version 1.1.1 to 1.1.2
15
index.js
@@ -28,7 +28,9 @@ module.exports = chainit; | ||
clearTimeout(flushTimeout); | ||
flushedTasks.unshift(function() { | ||
queue.push(task); | ||
process.nextTick(function() { | ||
flushedTasks.unshift(function() { | ||
queue.push(task); | ||
}); | ||
flushTimeout = setTimeout(flush, 4); | ||
}); | ||
flushTimeout = setTimeout(flush, 4); | ||
} | ||
@@ -97,2 +99,3 @@ | ||
var customCb; | ||
if (typeof args[args.length - 1] === 'function') { | ||
@@ -104,3 +107,2 @@ customCb = args.pop(); | ||
if (currentDepth > 0 && queues[currentDepth - 1].concurrency > 0) { | ||
@@ -111,2 +113,3 @@ queues[currentDepth - 1].concurrency = 0; | ||
var task = function(cb) { | ||
process.nextTick(function() { | ||
currentDepth = ldepth + 1; | ||
@@ -125,5 +128,7 @@ | ||
fn.apply(ctx, args); | ||
}); | ||
} | ||
pushTo(currentDepth, task); | ||
return this; | ||
@@ -130,0 +135,0 @@ } |
{ | ||
"name": "chainit", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Turn an asynchronous JavaScript api into an asynchronous chainable JavaScript api.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
20854
527