Function: union()
union<
ElementType>(...iterables:IterableResolvable<ElementType>[]):IterableIterator<ElementType>
Defined in: projects/utilities/packages/iterator-utilities/src/lib/union.ts:20
Creates an iterable with the elements that are in either input iterable.
Type Parameters
| Type Parameter | 
|---|
| ElementType | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| ... iterables | IterableResolvable<ElementType>[] | The iterators to combine. | 
Returns
IterableIterator<ElementType>
An iterator that yields the union of the provided iterators.
Example
import { union } from '@sapphire/iterator-utilities';
const iterable1 = [1, 2, 3];
const iterable2 = [3, 4, 5];
console.log([...union(iterable1, iterable2)]);
// Output: [1, 2, 3, 4, 5]