Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed use of Q#any and added test. #838

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion q.js
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,9 @@ function any(promises) {
}

Promise.prototype.any = function () {
return any(this);
return this.then(function(values) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be merely this.then(any).

return any(values);
});
};

/**
Expand Down
7 changes: 7 additions & 0 deletions spec/q-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,13 @@ describe("any", function() {
);
});

it("fulfills when called from the prototype", function() {
return Q(["a", "b"])
.any()
.then(function(result) {
expect(result).toEqual("a")
})
})
});

describe("allSettled", function () {
Expand Down