Function: zip()
zip<
Iterables
>(...iterables
:Iterables
):ZipIterators
<Iterables
>
Creates an iterable with the elements of the input iterables zipped together. The opposite of unzip
.
Type Parameters
Type Parameter |
---|
Iterables extends readonly IterableResolvable <any >[] |
Parameters
Parameter | Type | Description |
---|---|---|
...iterables | Iterables | The iterables to zip together. |
Returns
ZipIterators
<Iterables
>
A new iterable that yields the next value of each iterable in the list.
Example
import { zip } from '@sapphire/iterator-utilities';
const iterable1 = [1, 2, 3];
const iterable2 = ['a', 'b', 'c'];
const iterable3 = [true, false, true];
console.log(zip(iterable1, iterable2, iterable3));
// Output: [
// [1, 'a', true],
// [2, 'b', false],
// [3, 'c', true]
// ]
Defined in
projects/utilities/packages/iterator-utilities/src/lib/zip.ts:25