promise-fail

1.0.2 • Public • Published

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.22latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.22
1.0.10

Package Sidebar

Install

npm i promise-fail

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators

  • abdullahzn