1.0.0 • Published 2 years ago

promise.any2 v1.0.0

Weekly downloads
-
License
Unlicense
Repository
github
Last release
2 years ago

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)
})