Skip to content

Commit

Permalink
Fix #33 fix for calling any without a callback
Browse files Browse the repository at this point in the history
  • Loading branch information
briancavalier committed Apr 26, 2012
1 parent 6160fcf commit 1cf7d34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions test/any.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ buster.testCase('when.any', {
).then(done, done);
},

'should allow zero handlers': function(done) {
var input = [1, 2, 3];
when.any(input).then(
function(result) {
assert(contains(input, result));
},
fail
).then(done, done);
},

'should resolve to undefined when input promise does not resolve to array': function(done) {
when.any(resolved(1),
function(result) {
Expand Down
2 changes: 1 addition & 1 deletion when.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ define(function() {
function any(promisesOrValues, callback, errback, progressHandler) {

function unwrapSingleResult(val) {
return callback(val[0]);
return callback ? callback(val[0]) : val[0];
}

return some(promisesOrValues, 1, unwrapSingleResult, errback, progressHandler);
Expand Down

0 comments on commit 1cf7d34

Please sign in to comment.