@gourmet/promise-map
v0.3.3
Published
Promise aware version of JavaScript's `Array.prototype.map`
Downloads
6
Readme
@gourmet/promise-map
Promise aware version of JavaScript's Array.prototype.map
.
Basic usage
const map = require("@gourmet/promise-map");
function checkUrl(url) {
return somehowGetTheHttpStatusCodeFromTheUrl(url).then(status => {
return status === 200 ? "OK" : "Down";
});
}
map(["https://www.google.com", "https://github.com"], url => {
return checkUrl(url);
}).then(results => {
console.log(results); // ["OK", "OK"]
});