Skip to content

Commit

Permalink
Added keys method to promises and promise API.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Jan 5, 2011
1 parent e7da8aa commit 7ecde6f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ Deprecations:
please begin using the version of `defined` exported from
the latter module.

Next Minor Version:
0.2.3
- Added `keys` message to promises and to the promise API.

0.2.2
- Added boilerplate to `q/queue` and `q/util`.
- Fixed missing dependency to `q/queue`.

Expand Down
11 changes: 11 additions & 0 deletions lib/q.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ function ref(object) {
if (!method) throw new Error("No such method " + name + " on object " + object);
if (!method.apply) throw new Error("Property " + name + " on object " + object + " is not a method");
return object[name].apply(object, args);
},
"keys": function () {
return Object.keys(object);
}
}, undefined, function valueOf() {
return object;
Expand Down Expand Up @@ -443,6 +446,14 @@ exports.del = Method("del");
*/
exports.post = Method("post");

/**
* Requests the names of the owned properties of a promised
* object in a future turn.
* @param object promise or immediate reference for target object
* @return promise for the keys of the eventually resolved object
*/
exports.keys = Method("keys");

/**
* Guarantees that the give promise resolves to a defined, non-null value.
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "q",
"description": "defer/when-style promises (CommonJS/Promises/B)",
"version": "0.2.1",
"version": "0.2.3",
"homepage": "http://github.com/kriskowal/q/",
"author": "Kris Kowal <[email protected]> (http://github.com/kriskowal/)",
"contributors": [
Expand Down

0 comments on commit 7ecde6f

Please sign in to comment.