File size: 660 Bytes
e4a10af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const errors_1 = require("./errors");
async function PromiseEach(promises, ctor = Promise) {
    const results = await ctor.all(promises.map((promise) => promise instanceof ctor
        ? promise.then((resolved) => ({ resolved }), (rejected) => ({ rejected }))
        : promise));
    const rejections = new errors_1.ErrorBuffer();
    for (const result of results)
        if ("rejected" in result)
            rejections.add(result.rejected);
    rejections.check();
    return results.map(t => t.resolved);
}
exports.default = PromiseEach;
//# sourceMappingURL=PromiseEach.js.map