promise-catch

v0.0.1
Wrap a promise-generating function so its promises always resolve.

Unfinished util script

Setup

What

PromiseCatch turns this:

Promise.all([
    fs.readFileAsync('foo.jpg').catch(() => null),
    fs.readFileAsync('bar.jpg').catch(() => null)
]);

Into this:

Promise.all(promiseCatch([
    fs.readFileAsync('foo.jpg'),
    fs.readFileAsync('bar.jpg')
], null));

Assuming fs.readFileAsync returns a Promise. This can be achieved with a promise library like Bluebird.

Usage

Install

Arrays

Objects

Functions

Why

Calls to Promise.all and similar functions will fail at the first rejected promise. It is particularly useful to be able to avoid this when using generators to mimic the async/ await functionality of ES7.

npm i promise-catch

Metadata

  • ISC
  • Whatever
  • Unknown
  • released 8/29/2016

Downloads

Maintainers