From fd74cf878521bae46a868f3d5d8f90ae21a62a12 Mon Sep 17 00:00:00 2001 From: Natalie Wolfe Date: Wed, 19 Sep 2018 12:43:58 -0700 Subject: [PATCH] Fixed use of Q#any and added test. --- q.js | 4 +++- spec/q-spec.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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 () {