Skip to main content

allEqual

Callable

  • allEqual<Xs, As, T>(xs: Xs, as: As, eq?: (a: T, b: T) => boolean): boolean

  • Take two traversables and an equality function and returns true if all the elements of the first traversable are equal to the elements of the second traversable

    Example

    allEqual([1, 2, 3], [1, 2, 3])
    // => true

    allEqual([1, 2, 3], [1, 2])
    // => false

    allEqual([{foo: "bar"}], [{bar: "foo"}])
    // => false

    Alternatives


    Type parameters

    • Xs: Traversable<unknown, unknown>

      The type of the second iterator.

    • As: Traversable<unknown, unknown>

      The type of the first iterator.

    • T = Xs extends Traversable<S, unknown> ? S : never

      The element type.

    Parameters

    • xs: Xs

      The first traversable to compare.

    • as: As

      The second traversable to compare

    • eq: (a: T, b: T) => boolean = equal

      A predicate that checks if elements are equal, uses equal by default.

    Returns boolean

    This function returns true if all elements in the iterators are equal, and false otherwise.