Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes for when.any and when.some when handling object props

  • Loading branch information...
commit 084d7bcbb42a1e8b8703dc795a3e5e05935fed35 1 parent 78ba5ef
@briancavalier briancavalier authored
Showing with 10 additions and 3 deletions.
  1. +1 −1  test/some.js
  2. +9 −2 when.js
View
2  test/some.js
@@ -130,7 +130,7 @@ buster.testCase('when.some', {
when.some(expected, 1,
function(result) {
- assert.equals(result, expected);
+ assert.equals(result, { a: 1 });
},
fail
).then(done, done);
View
11 when.js
@@ -401,7 +401,14 @@ define(function() { "use strict";
} else {
results = {};
toResolve = 0;
- forEachKey(promisesOrValues, function () { toResolve++; });
+ // Could use Object.keys, but would need to shim it. So simply
+ // count the properties until we hit howMany or run out of props.
+ for(var p in promisesOrValues) {
+ if(owns.call(promisesOrValues, p)) {
+ toResolve++;
+ if(toResolve === howMany) break;
+ }
+ }
}
// No items in the input, resolve immediately
@@ -457,7 +464,7 @@ define(function() { "use strict";
return when(promisesOrValues, function(promisesOrValues) {
- return _reduce(promisesOrValues, reduceInto, []);
+ return _reduce(promisesOrValues, reduceInto, isObject(promisesOrValues) ? {} : []);
}).then(callback, errback, progressHandler);
}
Please sign in to comment.
Something went wrong with that request. Please try again.