Skip to main content

Function: greaterThan()

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

Determines if the elements of iterable are lexicographically greater than those of another.

Type Parameters

Type Parameter
ElementType

Parameters

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

Returns

boolean

Example

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

const x = [1, 2, 3, 4];
const y = [1, 4, 9, 16];
console.log(greaterThan([1], [1]));
// Output: false
console.log(greaterThan([1], [1, 2]));
// Output: false
console.log(greaterThan([1, 2], [1]));
// Output: true
console.log(greaterThan([1, 2], [1, 2]));
// Output: false

Remarks

This function consumes the entire iterator.

Defined in

projects/utilities/packages/iterator-utilities/src/lib/greaterThan.ts:32