Skip to main content

Function: drop()

drop<ElementType>(iterable: IterableResolvable<ElementType>, count: number): IterableIterator<ElementType>

Advances the iterable by count elements from the iterable.

Type Parameters

Type Parameter
ElementType

Parameters

ParameterTypeDescription
iterableIterableResolvable<ElementType>An iterator to drop values from.
countnumberThe number of elements to drop from the start of the iteration.

Returns

IterableIterator<ElementType>

An iterator that contains the elements of the provided iterator, except for the first count elements.

Example

import { drop } from '@sapphire/iterator-utilities';

const iterable = drop(iterator, 2);
console.log([...iterable]);
// Output: [3, 4, 5]

Defined in

projects/utilities/packages/iterator-utilities/src/lib/drop.ts:23