Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of arguments in "auto" in case of empty callback #966

Merged
merged 2 commits into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion test/test-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ exports['auto results'] = function(test){
});
};


exports['auto empty object'] = function(test){
async.auto({}, function(err){
test.ok(err === null, err + " passed instead of 'null'");
Expand Down Expand Up @@ -461,6 +460,13 @@ exports['auto no callback'] = function(test){
});
};

exports['auto concurrency no callback'] = function(test){
async.auto({
task1: function(callback){callback();},
task2: ['task1', function(callback){callback(); test.done();}]
}, 1);
};

exports['auto error should pass partial results'] = function(test) {
async.auto({
task1: function(callback){
Expand Down