@lou.codes/iterables
Version:
🔁 Iterable and AsyncIterable utils
17 lines (16 loc) • 500 B
TypeScript
/**
* Get the length of an iterable or asynchronous iterable.
*
* @category Asynchronous Reducers
* @example
* ```typescript
* length([1, 2, 3]); // 3
* ```
* @param iterable Iterable or asynchronous iterable to get the length from.
* @returns Promise with the length of the iterable.
*/
export declare const length: <
Iterable extends import("@lou.codes/types").IsomorphicIterable<unknown>,
>(
iterable: Iterable,
) => Iterable extends AsyncIterable<unknown> ? Promise<number> : number;