Function: dropWhile()
dropWhile(iterable, callbackFn)
dropWhile<
ElementType
,FilteredType
>(iterable
:IterableResolvable
<ElementType
>,callbackFn
: (element
:ElementType
,index
:number
) =>element is FilteredType
):IterableIterator
<Exclude
<ElementType
,FilteredType
>>
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.
Defined in
projects/utilities/packages/iterator-utilities/src/lib/dropWhile.ts:23
dropWhile(iterable, callbackFn)
dropWhile<
ElementType
>(iterable
:IterableResolvable
<ElementType
>,callbackFn
: (element
:ElementType
,index
:number
) =>boolean
):IterableIterator
<ElementType
>
Type Parameters
Type Parameter |
---|
ElementType |
Parameters
Parameter | Type |
---|---|
iterable | IterableResolvable <ElementType > |
callbackFn | (element : ElementType , index : number ) => boolean |
Returns
IterableIterator
<ElementType
>
Defined in
projects/utilities/packages/iterator-utilities/src/lib/dropWhile.ts:27