@lou.codes/iterables
Version:
🔁 Iterable and AsyncIterable utils
20 lines (19 loc) • 697 B
TypeScript
import type { ReadOnlyIterable } from "@lou.codes/types";
/**
* Takes two iterables and returns a new iterable with the length of the
* shortest iterable with tuples containing the items from both.
*
* @category 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: ReadOnlyIterable<ItemFirst>,
) => <ItemSecond>(
iterableSecond: ReadOnlyIterable<ItemSecond>,
) => Readonly<IterableIterator<readonly [ItemFirst, ItemSecond]>>;