pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
15 lines (14 loc) • 463 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapP = void 0;
const main_1 = require("./main");
function mapP(fn, coll) {
if (arguments.length === 1) {
return (_coll) => mapP(fn, _coll);
}
return (0, main_1.chain)(coll)
.bind((elements) => elements.map((element) => fn(element).then(main_1.getValue)))
.bind((promises) => Promise.all(promises))
.getValue();
}
exports.mapP = mapP;