summaryrefslogtreecommitdiff
path: root/dist/async.js
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2016-01-02 15:37:26 -0800
committerAlexander Early <alexander.early@gmail.com>2016-01-02 15:37:26 -0800
commit5a9383b3a2c554e19d96aa9918e5e26b37d773d7 (patch)
treef27641ef478f779313521293f2c9c3ece64254ef /dist/async.js
parent94868a2b8004952601eecbd8a72e43870a2a2b09 (diff)
downloadasync-5a9383b3a2c554e19d96aa9918e5e26b37d773d7.tar.gz
update minified build
Diffstat (limited to 'dist/async.js')
-rw-r--r--dist/async.js40
1 files changed, 22 insertions, 18 deletions
diff --git a/dist/async.js b/dist/async.js
index 8889344..9ecbda6 100644
--- a/dist/async.js
+++ b/dist/async.js
@@ -510,7 +510,7 @@
};
async.auto = function (tasks, concurrency, callback) {
- if (!callback) {
+ if (typeof arguments[1] === 'function') {
// concurrency is optional, shift the args.
callback = concurrency;
concurrency = null;
@@ -528,6 +528,8 @@
var results = {};
var runningTasks = 0;
+ var hasError = false;
+
var listeners = [];
function addListener(fn) {
listeners.unshift(fn);
@@ -550,6 +552,7 @@
});
_arrayEach(keys, function (k) {
+ if (hasError) return;
var task = _isArray(tasks[k]) ? tasks[k]: [tasks[k]];
var taskCallback = _restParam(function(err, args) {
runningTasks--;
@@ -562,6 +565,8 @@
safeResults[rkey] = val;
});
safeResults[k] = args;
+ hasError = true;
+
callback(err, safeResults);
}
else {
@@ -781,7 +786,7 @@
} else if (test.apply(this, args)) {
iterator(next);
} else {
- callback(null);
+ callback.apply(null, [null].concat(args));
}
});
iterator(next);
@@ -929,24 +934,23 @@
_insert(q, data, true, callback);
},
process: function () {
- if (!q.paused && workers < q.concurrency && q.tasks.length) {
- while(workers < q.concurrency && 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;
- });
+ while(!q.paused && workers < q.concurrency && q.tasks.length){
- if (q.tasks.length === 0) {
- q.empty();
- }
- workers += 1;
- workersList.push(tasks[0]);
- var cb = only_once(_next(q, tasks));
- worker(data, cb);
+ 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;
+ });
+
+ 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 () {