@quinck/collections
Version:
Allows extra operations on JavaScript collections: Array, Map and Set.
20 lines (19 loc) • 734 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require("./collect");
Array.prototype.awaitAll = async function () {
const _self = this;
return Promise.all(_self);
};
Array.prototype.tryToAwaitAll = async function () {
const _self = this;
return Promise.allSettled(_self);
};
Array.prototype.awaitAllFulfilled = async function () {
const _self = this;
return (await Promise.allSettled(_self)).singleCollect(({ status }) => status === 'fulfilled', result => result.value);
};
Array.prototype.awaitAllRejected = async function () {
const _self = this;
return (await Promise.allSettled(_self)).singleCollect(({ status }) => status === 'rejected', result => result.reason);
};