From 259c26c7668d93b2346cacdeeb8b023c5af0901f Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Oct 2015 00:58:32 +0100 Subject: [PATCH] Clean up --- lib/async.js | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/async.js b/lib/async.js index 700f30767..5c178197b 100644 --- a/lib/async.js +++ b/lib/async.js @@ -929,28 +929,23 @@ _insert(q, data, true, callback); }, process: function () { - if (!q.paused && workers < q.concurrency && q.tasks.length) { - while(workers < q.concurrency && q.tasks.length){ - if (q.paused) { - return; - } + while(!q.paused && workers < q.concurrency && q.tasks.length){ - var tasks = q.payload ? - q.tasks.splice(0, q.payload) : - q.tasks.splice(0, q.tasks.length); + var tasks = q.payload ? + q.tasks.splice(0, q.payload) : + q.tasks.splice(0, q.tasks.length); - var data = _map(tasks, function (task) { - return task.data; - }); + var data = _map(tasks, function (task) { + return task.data; + }); - if (q.tasks.length === 0) { - q.empty(); - } - workers += 1; - workersList.push(tasks[0]); - var cb = only_once(_next(q, tasks)); - worker(data, cb); + if (q.tasks.length === 0) { + q.empty(); } + workers += 1; + workersList.push(tasks[0]); + var cb = only_once(_next(q, tasks)); + worker(data, cb); } }, length: function () {