Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 20x 19x 18x 1x | const { mapIterable } = require('./helpers'), { validateIsIterable, validateIsFunction } = require('./validation'); /** * Async Map * * Map asynchronously and resolve when all callbacks are resolved * @async * @param {any[]} iterable * @param {Function} callback - callback(currentValue, index, array) * @param {any} [thisArg=undefined] * @return {Promise<any[]>} * @throws {TypeError} */ async function asyncMap(iterable, callback, thisArg = undefined) { validateIsIterable(iterable); validateIsFunction(callback); return Promise.all( mapIterable(iterable, callback.bind(thisArg), { useEmptyElements: false }) ); } module.exports = { asyncMap }; |