UNPKG

semantic-network

Version:

A utility library for manipulating a list of links that form a semantic interface to a network of resources.

48 lines 2.02 kB
import { __awaiter } from "tslib"; /** * Sequential resolution of promises across a collection. Returns when all resolutions have occurred. * * @param resource collection to iterate through all the items * @param iterator promise-based iterator * @returns the array of mapped representations that have been iterated across * @see parallelMapWaitAll */ export const sequentialMapWaitAll = (resource, iterator) => __awaiter(void 0, void 0, void 0, function* () { const arr = []; for (const item of resource.items) { arr.push(yield iterator(item)); } return arr; }); /** * Parallel resolution of promises across a collection. Returns when all resolutions have occurred. * * @param resource collection to iterate through all the items * @param iterator promise-based iterator * @returns the array of mapped representations that have been iterated across * @see sequentialMapWaitAll */ export const parallelMapWaitAll = (resource, iterator) => __awaiter(void 0, void 0, void 0, function* () { return yield Promise.all(resource.items.map((item) => __awaiter(void 0, void 0, void 0, function* () { return yield iterator(item); }))); }); /** * Sequential resolution of promises across a collection. Returns when all resolutions have occurred. * * @param resource collection to iterate through all the items * @param iterator promise-based iterator * @see parallelWaitAll */ export const sequentialWaitAll = (resource, iterator) => __awaiter(void 0, void 0, void 0, function* () { yield sequentialMapWaitAll(resource, iterator); }); /** * Parallel resolution of promises across a collection. Returns when all resolutions have occurred. * * @param resource collection to iterate through all the items * @param iterator promise-based iterator * @see sequentialWaitAll */ export const parallelWaitAll = (resource, iterator) => __awaiter(void 0, void 0, void 0, function* () { yield parallelMapWaitAll(resource, iterator); }); //# sourceMappingURL=promiseWaitAll.js.map