@lou.codes/iterables
Version:
🔁 Iterable and AsyncIterable utils
23 lines (22 loc) • 798 B
TypeScript
import type { IsomorphicIterable } from "@lou.codes/types";
/**
* Takes two iterables or asynchronous iterable and returns a new iterable or
* asynchronous iterable with the length of the shortest iterable with tuples
* containing the items from both.
*
* @category Asynchronous Generators
* @example
* ```typescript
* const zipNumbers = zip([0, 1, 2]);
* zipNumbers([3, 4, 5]); // [[0, 3], [1, 4], [2, 5]]
* ```
* @param iterableFirst One of the iterables to be zipped.
* @returns Curried function with `iterableFirst` in context.
*/
export declare const zip: <ItemFirst>(
iterableFirst: IsomorphicIterable<ItemFirst>,
) => <ItemSecond>(
iterableSecond: IsomorphicIterable<ItemSecond>,
) => Readonly<
AsyncIterableIterator<readonly [ItemFirst | Awaited<ItemFirst>, ItemSecond]>
>;