import { Awaitable, Obj, ValuesOf } from '../typescript'; /** * Maps an array of promises to a new array of values using a callback function. * * @param promises - An array of promises. * @param callback - A callback function that maps each resolved value to a new value. * * @returns - A promise that resolves to an array of mapped values. * * @template T - The type of the values in the input promises array. * @template R - The type of the values in the output array. */ export declare function mapPromises(promises: Promise[], callback: (item: T, index: number) => R): Promise; /** * Maps over an array of promises and applies a callback function to each item. * Returns a promise that resolves to an array of the mapped values. * * @param promises - The array of promises to map over. * @param callback - The callback function to apply to each item in the array. * It should return a promise or an awaitable value. * @returns A promise that resolves to an array of the mapped values. * * @template T - The type of the items in the input array. * @template R - The type of the mapped values. */ export declare function mapPromisedItems(promises: Promise, callback: (item: T, index: number) => Awaitable): Promise; export declare function reducePromises(promises: Promise[], aggregation: A, callback: (item: T) => [keyof A, ValuesOf]): Promise; /** * Reduces an array of promised items into a single object using the provided aggregation object and callback function. * * @param promises - The promises that resolve to an array of items. * @param aggregation - The initial aggregation object. * @param callback - The callback function that maps each item to a key-value pair. * * @returns - A promise that resolves to the final aggregation object. * * @template T - The type of the promised items. * @template A - The type of the aggregation object. */ export declare function reducePromisedItems(promises: Promise, aggregation: A, callback: (item: T) => [keyof A, ValuesOf]): Promise; /** * Merges an array of promises into a single promise that resolves to an array of values. * * @param promises - An array of promises. * * @returns - A promise that resolves to an array of values. * * @template T - The type of the resolved values. */ export declare function mergePromises(promises: Promise[]): Promise; /** * Counts the resolved values of an array of promises and returns the sum. * * @param promises - An array of promises that resolve to numbers. * * @returns A promise that resolves to the sum of the resolved values. */ export declare function countPromises(promises: Promise[]): Promise; /** * Waits for multiple promises to resolve and returns an array of resolved values. * * @param promises - An array of promises to wait for. * * @returns A promise that resolves to an array of resolved values. */ export declare function awaitResolved(promises: Promise[]): Promise; /** * Returns an array of rejected reasons from an array of promises. * * @param promises - An array of promises. * * @returns - A promise that resolves to an array of rejected reasons. * * @template T - The type of the rejected reasons. */ export declare function awaitRejected(promises: Promise[]): Promise; /** * Waits for multiple promises to settle and classifies the results into `resolved` and `rejected` arrays. * * @param promises - An array of promises to await. * * @returns A promise that resolves to an object containing the resolved and rejected values. * * @template T - The type of the resolved promises. * @template R - The type of the rejected promises. */ export declare function awaitClassified(promises: Promise[]): Promise<{ resolved: T[]; rejected: R[]; }>; /** * Asynchronously pauses the execution for the specified amount of time. * * @param timeout - The duration, in milliseconds, to pause the execution. * * @returns A promise that resolves after the specified timeout. */ export declare function sleep(timeout: number): Promise;