Function: all()
all(iterable, callbackFn)
all<
ElementType
,FilteredType
>(iterable
:IterableResolvable
<ElementType
>,callbackFn
: (element
:ElementType
,index
:number
) =>element is FilteredType
):iterable is IterableIterator<FilteredType>
Tests whether all elements in the iterable pass the test implemented by the provided function.
Type Parameters
Type Parameter |
---|
ElementType |
FilteredType |
Parameters
Parameter | Type | Description |
---|---|---|
iterable | IterableResolvable <ElementType > | The iterator to check. |
callbackFn | (element : ElementType , index : number ) => element is FilteredType | A function to execute for each element produced by the iterator. It should return a truthy value to indicate the element passes the test, and a falsy value otherwise. |
Returns
iterable is IterableIterator<FilteredType>
true
if callbackFn returns a truthy value for every element. Otherwise, false
.
Example
import { every } from '@sapphire/iterator-utilities';
const iterable = [1, 2, 3, 4, 5];
console.log(every(iterable, (value) => value < 10));
// Output: true
console.log(every(iterable, (value) => value < 3));
// Output: false
Remarks
This function consumes the entire iterator.
Defined in
projects/utilities/packages/iterator-utilities/src/lib/every.ts:28
all(iterable, callbackFn)
all<
ElementType
>(iterable
:IterableResolvable
<ElementType
>,callbackFn
: (element
:ElementType
,index
:number
) =>boolean
):boolean
Type Parameters
Type Parameter |
---|
ElementType |
Parameters
Parameter | Type |
---|---|
iterable | IterableResolvable <ElementType > |
callbackFn | (element : ElementType , index : number ) => boolean |
Returns
boolean
Defined in
projects/utilities/packages/iterator-utilities/src/lib/every.ts:32