Function: equalBy()
equalBy<
ElementType
>(iterable
:IterableResolvable
<ElementType
>,other
:IterableResolvable
<ElementType
>,callbackFn
: (x
:ElementType
,y
:ElementType
) =>boolean
):boolean
Determines if the elements of both iterators are equal with respect to the specified equality function.
Type Parameters
Type Parameter |
---|
ElementType |
Parameters
Parameter | Type | Description |
---|---|---|
iterable | IterableResolvable <ElementType > | The iterator to compare. |
other | IterableResolvable <ElementType > | The iterator to compare against. |
callbackFn | (x : ElementType , y : ElementType ) => boolean | - |
Returns
boolean
Whether the two iterators are equal with respect to the specified equality function.
Example
import { equalBy } from '@sapphire/iterator-utilities';
const x = [1, 2, 3, 4];
const y = [1, 4, 9, 16];
console.log(equalBy(x, y, (a, b) => a * a === b));
// Output: true
Remarks
This function consumes the entire iterator.
Defined in
projects/utilities/packages/iterator-utilities/src/lib/equalBy.ts:27