1.0.2 • Published 7 years ago

promise-fail v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

promise-fail

Promise.all for failures Check if all promises fail

> npm install promise-fail || yarn add promise-fail

Require module

Promise.fail = require('promise-fail'); // why not
// or
const checkPromisesFailure = require('promise-fail');

Usage

This module checks if all Promises given in arguments fail and returns the first non-failing Promise

const p1 = Promise.reject(true);
const p2 = Promise.reject(true);
const p3 = Promise.reject(true);
const p4 = Promise.resolve("YES");

// this will print 'All promises have failed'
Promise.fail([ p1, p2, p3 ])
  .then(() => console.log("All promises have failed"))
  .catch(promise => console.log(promise));

// this will print 'Promise { 'YES' }' or alike
Promise.fail([ p1, p4 ])
  .then(() => console.log("All promises have failed"))
  .catch(promise => console.log(promise));