promise-guard
Resolve a collection of Promises while guarding against certain rejections
Install
$ npm install --save promise-guard
Usage
promiseGuard(<promises>, <map>, <filter>)
Given an array or object of promises, attemps to resolve them to an array or object of the resolved values. Converts rejected promises for which filter(error)
is true, to resolved values of map(error)
. Returns a rejected promise if any rejection does not pass the filter.
<map>
defaults tofunction(x) { return x }
<filter>
defaults tofunction() { return true }
var promiseGuard = // resolves to ['a', 'z'] // rejects to 'c' // resolves to [1,2,3] // resolves to { a:1, b:null }
License
ISC © Raine Lourie