1.0.0 • Published 7 years ago
promise.mapper v1.0.0
promise.mapper
"Returns a promise containing the result of the promisified mappingFn on its elements. Order is preserved. Additionally, rejection occurs if any of the promises reject.
Install
$ npm install promise.mapper --save
Usage
var map = require('promise.mapper')
var makeRequest = (input) => http.Get(input).then(data => data.statusCode)
map([
'test.com',
'malwarehacks42.ru'
requestGoogle, // promise
], makeRequest).then((result) => {
console.log(result) // [200, 400, 200]
})
API
map(input..., mapperFn)
-> promise
Returns a promise containing the result of the promisified mappingFn on its elements. Order is preserved. Additionally, rejection occurs if any of the promises reject.
input Iterable<Promise|any>
A sequence of promises or instanceof Iterable
mapperFn Function
A mapping function that returns a promise
1.0.0
7 years ago