Skip to content

Commit

Permalink
Do not return the promise from the deferred's methods.
Browse files Browse the repository at this point in the history
See discussion in kriskowal#135.
  • Loading branch information
domenic committed Nov 4, 2012
1 parent 0442ffa commit 87d9254
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions q.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,14 @@ function defer() {
}, void 0);
pending = void 0;
progressListeners = void 0;
return value;
}

defend(promise);

deferred.promise = promise;
deferred.resolve = become;
deferred.reject = function (exception) {
return become(reject(exception));
become(reject(exception));
};
deferred.notify = function (progress) {
if (pending) {
Expand Down
5 changes: 5 additions & 0 deletions spec/q-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ describe("defer and when", function () {
return promise;
});

it("returns `undefined` from the deferred's methods", function () {
expect(Q.defer().resolve()).toBe(undefined);
expect(Q.defer().reject()).toBe(undefined);
});

});

describe("always next tick", function () {
Expand Down

0 comments on commit 87d9254

Please sign in to comment.