/** * Type representing an async iteration callback function. * @template TError - Error type * @template T - Argument array type * @template TReturn - Return type */ export type NextFunction = (error?: TError, ...args: T) => TReturn; /** * Simplified version of NextFunction for cases without arguments. * @template T - Error type */ export type SimpleNextFunction = NextFunction>; /** * Represents an error that aggregates multiple errors from asynchronous iterations. * @class * @extends {Error} * @property {Error[]} errors - The array of errors that occurred during iteration. */ export declare class AggregateErrors extends Error { readonly errors: Error[]; constructor(errors: Error[]); } /** * Asynchronously iterates over elements of an array-like structure. * @param {T[] | ArrayLike} array - Array-like structure to iterate over * @param {(element: T, i: number) => Promise} body - Async callback executed for each element * @param {boolean} waitForPrevious - Whether to wait for previous iteration to complete before next * @returns {Promise} Resolves when all iterations complete */ export declare function array(array: T[] | ArrayLike, body: (element: T, i: number) => Promise, waitForPrevious: boolean): Promise; /** * Asynchronously iterates over key-value pairs of an object. * @param {T} o - Object to iterate over * @param {(element: T[keyof T], i: keyof T) => Promise} body - Async callback for each key-value pair * @param {boolean} waitForPrevious - Whether to wait for previous iteration to complete * @returns {Promise} Resolves when all iterations complete */ export declare function object(o: T, body: (element: T[keyof T], i: keyof T) => Promise, waitForPrevious: boolean): Promise; /** * Unified async iteration entry point for arrays/objects. * @function * @param {T[] | ArrayLike | Record} it - Iterable structure to process * @param {(element: unknown, i: any) => Promise} body - Async iteration callback * @param {boolean} [waitForPrevious=true] - Whether to wait for previous iteration to complete * @returns {Promise} Resolves when all iterations complete */ export declare function each(array: T[] | ArrayLike, body: (element: T, i?: number) => Promise, waitForPrevious?: boolean): Promise; export declare function each>(o: T, body: (element: T[typeof i], i: keyof T) => Promise, waitForPrevious?: boolean): Promise; /** * Asynchronously maps elements of an array-like structure to new values. * @param {T[] | ArrayLike} it - Array-like structure to process * @param {(element: T, i: number) => Promise} body - Async transformation function * @param {boolean} waitForPrevious - Whether to wait for previous iteration * @returns {Promise} Promise resolving to transformed elements */ export declare function mapArray(it: T[] | ArrayLike, body: (element: T, i: number) => Promise, waitForPrevious: boolean): Promise; /** * Asynchronously maps key-value pairs of an object to new values. * @param {TIn} o - Source object to process * @param {(element: TIn[keyof TIn], i: keyof TIn) => TResultValue} body - Transformation function * @param {boolean} asArray - Return results as array instead of object * @param {boolean} waitForPrevious - Whether to wait for previous iteration * @returns {Promise>>} Transformed results */ export declare function mapObject(o: TIn, body: (element: TIn[keyof TIn], i: keyof TIn) => TResultValue, asArray: true, waitForPrevious: boolean): Promise; export declare function mapObject(o: TIn, body: (element: TIn[keyof TIn], i: keyof TIn) => TResultValue, asArray: false, waitForPrevious: boolean): Promise<{ [P in keyof TIn]?: TResultValue; }>; export declare function mapObject(o: TIn, body: (element: TIn[keyof TIn], i: keyof TIn) => TResultValue, asArray: boolean, waitForPrevious: boolean): any; /** * Unified async mapping function for arrays/objects. * @function * @param {T[] | ArrayLike | Record} it - Iterable structure to process * @param {(element: any, i: any) => any} body - Async mapping function * @param {boolean} [asArray=false] - Return results as array * @param {boolean} [waitForPrevious=true] - Whether to wait between iterations * @returns {Promise} Transformed results based on input type */ export declare function map(array: T[] | ArrayLike, body: (element: T, i: number) => Promise, asArray: true, waitForPrevious?: boolean): Promise; export declare function map(array: T[] | ArrayLike, body: (element: T, i: number) => Promise, asArray: boolean, waitForPrevious?: boolean): Promise; export declare function map(o: TIn, body: (element: TIn[TKey], i: TKey) => Promise, asArray?: false, waitForPrevious?: boolean): Promise>; export declare function map(o: TIn, body: (element: TIn[TKey], i: TKey) => Promise, asArray: true, waitForPrevious?: boolean): Promise; /** * Asynchronously filters elements of an array-like structure. * @param {T[] | ArrayLike} it - Array-like structure to filter * @param {(element: T, i: number) => Promise} body - Async predicate function * @param {boolean} waitForPrevious - Whether to wait for previous iteration * @returns {Promise} Filtered elements */ export declare function grepArray(it: T[] | ArrayLike, body: (element: T, i: number) => Promise, waitForPrevious: boolean): Promise; export type Proxy = { [P in keyof T]: U; }; /** * Asynchronously filters key-value pairs of an object. * @param {T} o - Object to filter * @param {(element: T[keyof T], i: keyof T) => Promise} body - Async predicate function * @param {boolean} asArray - Return results as array * @param {boolean} waitForPrevious - Whether to wait for previous iteration * @returns {Promise>} Filtered results */ export declare function grepObject(o: T, body: (element: T[keyof T], i: keyof T) => Promise, asArray: true, waitForPrevious: boolean): Promise; export declare function grepObject(o: T, body: (element: T[keyof T], i: keyof T) => Promise, asArray: false, waitForPrevious: boolean): Promise>; export declare function grepObject(o: T, body: (element: T[keyof T], i: keyof T) => Promise, asArray: boolean, waitForPrevious: boolean): Promise | T[keyof T][]>; /** * Unified async filter function for arrays/objects. * @function * @param {T[] | ArrayLike | Record} it - Iterable structure to process * @param {(element: any, i: any) => Promise} body - Async predicate function * @param {boolean} [asArray=false] - Return results as array * @param {boolean} [waitForPrevious=true] - Whether to wait between iterations * @returns {Promise} Filtered results based on input type */ export declare function grep(array: T[] | ArrayLike, body: (element: T, i: number) => Promise, waitForPrevious?: boolean): Promise; export declare function grep(o: T, body: (element: T[U], i: U) => Promise, waitForPrevious?: boolean): Promise>; export declare function grep(o: T, body: (element: T[U], i: U) => Promise, asArray: true, waitForPrevious?: boolean): Promise;