diff --git a/q.js b/q.js index 6e467958..a21a4ca1 100644 --- a/q.js +++ b/q.js @@ -1665,7 +1665,9 @@ function any(promises) { } Promise.prototype.any = function () { - return any(this); + return this.then(function(values) { + return any(values); + }); }; /** diff --git a/spec/q-spec.js b/spec/q-spec.js index 46d913fb..3eb07d9c 100644 --- a/spec/q-spec.js +++ b/spec/q-spec.js @@ -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 () {