2.1.0-alpha.6 • Published 5 years ago
typescript-promise-any v2.1.0-alpha.6
promise.any 
ES Proposal 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 proposed spec.
Most common usage:
import assert from "assert";
import any from "promise.any";
const resolved = Promise.resolve(42);
const rejected = Promise.reject(-1);
const alsoRejected = Promise.reject(Infinity);
any([resolved, rejected, alsoRejected]).then(result => {
assert.equal(result, 42);
});
any([rejected, alsoRejected]).catch((error) => {
assert.ok(error instanceof AggregateError);
assert.deepEqual(error.errors, [-1, Infinity]);
});
any.shim(); // will be a no-op if not needed
Promise.any([resolved, rejected, alsoRejected]).then(result => {
assert.equal(result, 42);
});
Promise.any([rejected, alsoRejected]).catch(error => {
assert.ok(error instanceof AggregateError);
assert.deepEqual(error.errors, [-1, Infinity]);
});Tests
Simply clone the repo, npm install, and run npm test
Pre-1.0 versions
The promise.any package was released as now-deprecated v0.1.0 and v0.1.1, as a fork of https://github.com/m0ppers/promise-any.
Thanks to @sadorlovsky for donating the repo and the promise.any npm package!
2.1.0-alpha.6
5 years ago
2.1.0-alpha.5
5 years ago
2.1.0-alpha.4
5 years ago
2.1.0-alpha.3
5 years ago
2.1.0-alpha.2
5 years ago
2.1.0-alpha.1
5 years ago
