Skip to main content

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

ParameterTypeDescription
iterableIterableResolvable<ElementType>The iterator to append values to.
...iterablesIterableResolvable<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]

Source

projects/utilities/packages/iterator-utilities/src/lib/append.ts:20