UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

18 lines (17 loc) 701 B
/** * Executes an array of promises in parallel and returns their results. * @param {Promise<T>[]} promises - An array of promises to execute. * @returns {Promise<(T | Error)[]>} A promise that resolves to an array of results or errors. * @template T - Type of the successful promise result * @template E - Type of the error, defaults to Error * @throws {TypeError} When the input is not an array * @example * const promises = [ * Promise.resolve(1), * Promise.reject('Error'), * Promise.resolve(3) * ]; * const results = await parallel(promises); * // results will be [1, Error: 'Error', 3] */ export declare function parallel<T>(promises: Promise<T>[]): Promise<(T | Error)[]>;