• Creates a Comparator that compares the elements of two Iterables pairwise.

    Finds the first unequal pair and returns the result

    If all pairs are equal, the number of elements of the Iterables will be used for the comparison result.

    Example

    Compare Iterables of numbers

    const numberIterableComparator = iterableComparator(numberComparator);
    const result = numberIterableComparator([1, 2], [1, 1]);
    console.log(result); // 1

    Example

    Compare Iterables with different lengths

    const numberIterableComparator = iterableComparator(numberComparator);
    const result = numberIterableComparator([1, 1], [2]);
    console.log(result); // 1

    Returns

    a Comparator for Iterables of type T

    Type Parameters

    • T

      the Iterable value type

    Parameters

    • comparator: Comparator<T>

      the Comparator to use for the comparison of the elements

    Returns Comparator<Iterable<T>>

Generated using TypeDoc