Function: dropWhile()
Call Signature
dropWhile<
ElementType,FilteredType>(iterable:IterableResolvable<ElementType>,callbackFn: (element:ElementType,index:number) =>element is FilteredType):IterableIterator<Exclude<ElementType,FilteredType>>
Defined in: projects/utilities/packages/iterator-utilities/src/lib/dropWhile.ts:23
Creates a new iterator without the elements that satisfy the specified test.
Type Parameters
| Type Parameter | 
|---|
| ElementType | 
| FilteredType | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| iterable | IterableResolvable<ElementType> | An iterator to drop values from. | 
| callbackFn | ( element:ElementType,index:number) =>element is FilteredType | A function to execute for each element produced by the iterator. It should return a falsy value to make the element yielded by the iterator helper, and a truthy value otherwise. | 
Returns
IterableIterator<Exclude<ElementType, FilteredType>>
An iterator that produces elements from the given iterator that don't satisfy the specified test.
Example
import { dropWhile } from '@sapphire/iterator-utilities';
const iterable = dropWhile([1, 2, 3, 4, 5], (value) => value < 3);
console.log([...iterable]);
// Output: [3, 4, 5]
Seealso
filter or takeWhile for the opposite behavior.
Call Signature
dropWhile<
ElementType>(iterable:IterableResolvable<ElementType>,callbackFn: (element:ElementType,index:number) =>boolean):IterableIterator<ElementType>
Defined in: projects/utilities/packages/iterator-utilities/src/lib/dropWhile.ts:27
Creates a new iterator without the elements that satisfy the specified test.
Type Parameters
| Type Parameter | 
|---|
| ElementType | 
Parameters
| Parameter | Type | Description | 
|---|---|---|
| iterable | IterableResolvable<ElementType> | An iterator to drop values from. | 
| callbackFn | ( element:ElementType,index:number) =>boolean | A function to execute for each element produced by the iterator. It should return a falsy value to make the element yielded by the iterator helper, and a truthy value otherwise. | 
Returns
IterableIterator<ElementType>
An iterator that produces elements from the given iterator that don't satisfy the specified test.
Example
import { dropWhile } from '@sapphire/iterator-utilities';
const iterable = dropWhile([1, 2, 3, 4, 5], (value) => value < 3);
console.log([...iterable]);
// Output: [3, 4, 5]