UNPKG

@serenity-js/core

Version:

The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure

17 lines 551 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.asyncMap = asyncMap; /** * Maps an Array<Item_Type> to an Array<Result_Type>, one element at a time. * * @param items * @param mappingFunction */ function asyncMap(items, mappingFunction) { return Promise.resolve().then(() => items.reduce((previous, item) => previous.then(async (acc) => { const result = await mappingFunction(item); acc.push(result); return acc; }), Promise.resolve([]))); } //# sourceMappingURL=asyncMap.js.map