The primary sequence whose elements lead each pair.
The secondary sequence whose elements are paired with source.
Optionalzipper: Zipper<TElement, TSecond, TResult>Optional projection invoked with each [source, other] pair. When omitted, the tuples [source, other] are emitted.
A deferred sequence of projected results truncated to the length of the shorter input.
Re-throws any error thrown while iterating either input sequence or executing zipper.
Enumeration is lazy; pairs are produced on demand and iteration stops as soon as either input completes.
const numbers = [1, 2, 3];
const letters = ['a', 'b', 'c'];
const zipped = zip(numbers, letters).toArray();
console.log(zipped); // [[1, 'a'], [2, 'b'], [3, 'c']]
const zippedWithSelector = zip(numbers, letters, (num, letter) => `${num}-${letter}`).toArray();
console.log(zippedWithSelector); // ['1-a', '2-b', '3-c']
Combines source with other and optionally projects each aligned pair using zipper.