promise.any2
v1.0.0
Published
Promise.any() implementation
Downloads
2
Readme
ES6 promises don't provide any(). A small library to implement them. Will convert arguments to promises if not already a promise.
Installation
Using npm:
npm install promise.any2 --save
Import
ESModule
import 'promise.any2'
CommonJS
require('promise.any2')
Browser
<script src="https://cdn.jsdelivr.net/npm/promise.any2"></script>
Usage
Promise.any([Promise.reject('✗'), Promise.resolve('✓')]).then(function (value) {
// value is '✓' :)
console.log(value)
})
Promise.any([Promise.reject('✗'), Promise.reject('✗')]).catch(function (reasons) {
// reasons is ['✗', '✗'] :(
console.log(reasons)
})