Skip to content

Commit

Permalink
fixes #1338
Browse files Browse the repository at this point in the history
  • Loading branch information
petkaantonov committed Mar 3, 2017
1 parent 1d9cba4 commit c5b3ef3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"RESOLVE_OBJECT": false,
"RESOLVE_FOREVER_PENDING": false,
"RESOLVE_CALL_METHOD": false,
"RESOLVE_MAP": false,
"QUEUE_MAX_CAPACITY": false,
"QUEUE_MIN_CAPACITY": false,
"FROM_PREVIOUS_EVENT": false,
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ CONSTANT(RESOLVE_ARRAY, -2);
CONSTANT(RESOLVE_OBJECT, -3);
CONSTANT(RESOLVE_FOREVER_PENDING, -4);
CONSTANT(RESOLVE_CALL_METHOD, -5);
CONSTANT(RESOLVE_MAP, -6);

//queue.js
CONSTANT(QUEUE_MAX_CAPACITY, (1 << 30) | 0);
Expand Down
1 change: 1 addition & 0 deletions src/promise_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function toResolutionValue(val) {
switch(val) {
case RESOLVE_ARRAY: return [];
case RESOLVE_OBJECT: return {};
case RESOLVE_MAP: return new Map();
}
ASSERT(false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function PropertiesPromiseArray(obj) {
}
this.constructor$(entries);
this._isMap = isMap;
this._init$(undefined, RESOLVE_OBJECT);
this._init$(undefined, isMap ? RESOLVE_MAP : RESOLVE_OBJECT);
}
util.inherits(PropertiesPromiseArray, PromiseArray);

Expand Down
7 changes: 7 additions & 0 deletions test/mocha/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ describe("Promise.props", function () {
});
});


if (typeof Map !== "undefined") {
specify("works with es6 maps", function() {
return Promise.props(new Map([
Expand Down Expand Up @@ -208,6 +209,12 @@ describe("Promise.props", function () {
assert.strictEqual(result.get(c), 3);
});
});

specify("empty map should resolve to empty map", function() {
return Promise.props(new Map()).then(function(result) {
assert(result instanceof Map);
});
});
}

});

0 comments on commit c5b3ef3

Please sign in to comment.