[Pkg-javascript-commits] [node-async] 284/480: Partial results should include the current task
Jonas Smedegaard
js at moszumanska.debian.org
Fri May 2 08:58:34 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository node-async.
commit dd7ce2eb799ba3590079487b5e6c53f2157001f4
Author: Michael Leaney <leahcimic at gmail.com>
Date: Wed Feb 13 19:50:03 2013 +1100
Partial results should include the current task
---
lib/async.js | 15 ++++++++++-----
test/test-async.js | 3 ++-
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/async.js b/lib/async.js
index 9bcc82e..a576eee 100755
--- a/lib/async.js
+++ b/lib/async.js
@@ -425,16 +425,21 @@
_each(keys, function (k) {
var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k];
var taskCallback = function (err) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ if (args.length <= 1) {
+ args = args[0];
+ }
if (err) {
- callback(err, results);
+ var safeResults = {};
+ _each(_keys(results), function(rkey) {
+ safeResults[rkey] = results[rkey];
+ });
+ safeResults[k] = args;
+ callback(err, safeResults);
// stop subsequent errors hitting callback multiple times
callback = function () {};
}
else {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
results[k] = args;
async.nextTick(taskComplete);
}
diff --git a/test/test-async.js b/test/test-async.js
index b447483..7551de6 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -299,7 +299,7 @@ exports['auto error should pass partial results'] = function(test) {
callback(false, 'result1');
},
task2: ['task1', function(callback){
- callback('testerror');
+ callback('testerror', 'result2');
}],
task3: ['task2', function(callback){
test.ok(false, 'task3 should not be called');
@@ -308,6 +308,7 @@ exports['auto error should pass partial results'] = function(test) {
function(err, results){
test.equals(err, 'testerror');
test.equals(results.task1, 'result1');
+ test.equals(results.task2, 'result2');
});
setTimeout(test.done, 100);
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git
More information about the Pkg-javascript-commits
mailing list