Function: append()
append<
ElementType
>(iterable
:IterableResolvable
<ElementType
>, ...iterables
:IterableResolvable
<ElementType
>[]):IterableIterator
<ElementType
>
Appends iterables to the end of the first iterable, returning a new iterable combining all of them. It's similar to concatenating arrays or doing [...a, ...b, ...c]
.
Type Parameters
Type Parameter |
---|
ElementType |
Parameters
Parameter | Type | Description |
---|---|---|
iterable | IterableResolvable <ElementType > | The iterator to append values to. |
...iterables | IterableResolvable <ElementType >[] | The iterables to append to the iterator. |
Returns
IterableIterator
<ElementType
>
An iterator that yields the values of the provided iterator followed by the values of the provided iterables.
Example
import { append } from '@sapphire/iterator-utilities';
const iterable = append([1, 2, 3], [4, 5, 6], [7, 8, 9]);
console.log([...iterable]);
// Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Defined in
projects/utilities/packages/iterator-utilities/src/lib/append.ts:20