0.0.1 • Published 8 years ago

promise-catch v0.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
8 years ago

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.