Skip to main content

zipWith

zipWith() function

Returns Iterable/AsyncIterable out of the two supplied by applying f to each same positioned pair in Iterable/AsyncIterable.

Signature:
declare function zipWith<A, B, C>(f: (a: A, b: B) => C, iterable1: Iterable<A>, iterable2: Iterable<B>): IterableIterator<C>;

declare function zipWith<A, B, C>(f: (a: A, b: B) => C, iterable1: Iterable<A>, iterable2: AsyncIterable<B>): AsyncIterableIterator<C>;

declare function zipWith<A, B, C>(f: (a: A, b: B) => C, iterable1: AsyncIterable<A>, iterable2: Iterable<B>): AsyncIterableIterator<C>;

declare function zipWith<A, B, C>(f: (a: A, b: B) => C, iterable1: AsyncIterable<A>, iterable2: AsyncIterable<B>): AsyncIterableIterator<C>;

Example

const iter = zipWith((a,b) => [a,b], [1,2,3], ['a','b','c']);
iter.next(); // {value: [1, 'a'] , done: false}
iter.next(); // {value: [2, 'b'] , done: false}
iter.next(); // {value: [3, 'c'] , done: false}
iter.next(); // {value: undefined , done: true}

Open Source Code