Skip to content

Commit

Permalink
Revise chaining of put and del
Browse files Browse the repository at this point in the history
So chaining put and del messages is more useful.

Fixes kriskowal#84.
  • Loading branch information
kriskowal committed Aug 23, 2012
1 parent 795fd1c commit b160c43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions q.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,10 +789,12 @@ function resolve(object) {
return object[name];
},
"put": function (name, value) {
return object[name] = value;
object[name] = value;
return object;
},
"del": function (name) {
return delete object[name];
delete object[name];
return object;
},
"post": function (name, value) {
return object[name].apply(object, value);
Expand Down
4 changes: 2 additions & 2 deletions spec/q-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ describe("promises for objects", function () {
return Q.resolve(object)
.put('a', 1)
.then(function (result) {
expect(result).toBe(1); // not supported. may change in future version.
expect(result).toBe(object);
expect(object.a).toBe(1);
});
});
Expand Down Expand Up @@ -509,7 +509,7 @@ describe("promises for objects", function () {
.del('a')
.then(function (result) {
expect('a' in object).toBe(false);
expect(result).toBe(true); // not supported, may change
expect(result).toBe(object);
}, function (exception) {
expect("up").toBe("down");
});
Expand Down

0 comments on commit b160c43

Please sign in to comment.