Skip to main content

Function: equal()

equal<ElementType>(iterable: IterableResolvable<ElementType>, other: IterableResolvable<ElementType>): boolean

Determines if the elements of both iterators are equal.

Type Parameters

Type Parameter
ElementType

Parameters

ParameterTypeDescription
iterableIterableResolvable<ElementType>The iterator to compare.
otherIterableResolvable<ElementType>The iterator to compare against.

Returns

boolean

Whether the two iterators are equal.

Example

import { equal } from '@sapphire/iterator-utilities';

console.log(equal([1], [1]));
// Output: true
console.log(equal([1], [1, 2]));
// Output: false

Remarks

This function consumes the entire iterator.

Defined in

projects/utilities/packages/iterator-utilities/src/lib/equal.ts:25