You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ES 2021 spec-compliant shim for Promise.any. Invoke its "shim" method to shim Promise.any if it is unavailable or noncompliant. Note: a global Promise must already exist: the es6-shim is recommended.
This package implements the es-shim API interface. It works in an ES3-supported environment that has Promise available globally, and complies with the spec.
Most common usage:
varassert=require('assert');varany=require('promise.any');varresolved=Promise.resolve(42);varrejected=Promise.reject(-1);varalsoRejected=Promise.reject(Infinity);any([resolved,rejected,alsoRejected]).then(function(result){assert.equal(result,42);});any([rejected,alsoRejected]).catch(function(error){assert.ok(errorinstanceofAggregateError);assert.deepEqual(error.errors,[-1,Infinity]);});any.shim();// will be a no-op if not neededPromise.any([resolved,rejected,alsoRejected]).then(function(result){assert.equal(result,42);});Promise.any([rejected,alsoRejected]).catch(function(error){assert.ok(errorinstanceofAggregateError);assert.deepEqual(error.errors,[-1,Infinity]);});
Tests
Simply clone the repo, npm install, and run npm test