Function: dropLast()
dropLast<
ElementType>(iterable:IterableResolvable<ElementType>,count:number):IterableIterator<ElementType>
Defined in: projects/utilities/packages/iterator-utilities/src/lib/dropLast.ts:28
Consumes the iterable, creating a new iterator without the last count elements from the iterable.
Type Parameters
| Type Parameter | 
|---|
| ElementType | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| iterable | IterableResolvable<ElementType> | An iterator to drop values from. | 
| count | number | The number of values to drop from the end of the iterator. | 
Returns
IterableIterator<ElementType>
An iterator that contains the elements of the provided iterator, except for the last count elements.
Example
import { dropLast } from '@sapphire/iterator-utilities';
const iterable = dropLast([1, 2, 3, 4, 5], 2);
console.log([...iterable]);
// Output: [1, 2, 3]
Remarks
This function consumes the entire iterator.