ciorent
Version:
A lightweight, low-overhead concurrency library
30 lines (29 loc) • 900 B
TypeScript
/**
* Async `Array.prototype.map`. **Mutates** the original array.
*
* @example
* await Promise.all(
* map([task1(), task2(), task3()], (taskResult) => taskResult.debug)
* );
*
* // Map without mutating the original array
* await Promise.all(
* map(taskPromises.slice(), (taskResult) => taskResult.debug)
* );
*/
export declare const map: <
T,
R
>(arr: Promise<T>[], fn: (value: T) => R | Promise<R>) => Promise<R>[];
/**
* Async `Array.prototype.find`.
*/
export declare const find: <T>(arr: Promise<T>[], fn: (value: T) => boolean | Promise<boolean>) => Promise<T | undefined>;
/**
* Async `Array.prototype.some`.
*/
export declare const some: <T>(arr: Promise<T>[], fn: (value: T) => boolean | Promise<boolean>) => Promise<boolean>;
/**
* Async `Array.prototype.every`.
*/
export declare const every: <T>(arr: Promise<T>[], fn: (value: T) => boolean | Promise<boolean>) => Promise<boolean>;