export type TGetAsyncMapArgs = Parameters; export type TGetAsyncMapReturn = ReturnType; /** * Gets an aggregated result of async operation for each element of given Array * @template T,U * @param {Array} arr source array * @param {(value: T, index: number, array: T[]) => Promise|U} callback callback function (can be sync or async) * @returns {Promise>} * @throws {TypeError} getAsyncMap: arr must be an array * @throws {TypeError} getAsyncMap: callback must be a function * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all * @example * // How to call API for each element of an array and return a result? * const myAPIFn = (item, index, arr) => Promise.resolve("success" + item); * const array = [ 1, 2, 3 ]; * const result = await getAsyncMap(array, myAPIFn); * console.log(result); // => [ "success1", "success2", "success3" ] * @example * // Fetch user profiles for every ID in parallel * const users = await getAsyncMap(userIds, async (id) => { * const response = await fetch(`/api/users/${id}`); * return response.json(); * }); */ export declare const getAsyncMap: (arr: T[], callback: (value: T, index: number, array: T[]) => Promise | U) => Promise;