Prelude API
    Preparing search index...

    Function diff

    • Creates a generator that produces pairs showing differences between two iterables.

      Type Parameters

      • Lhs

        Type of elements in the left-hand side iterable

      • Rhs

        Type of elements in the right-hand side iterable

      • Comparable = Lhs & Rhs

        Type used for comparison, defaults to intersection of Lhs & Rhs

      Parameters

      • rhsValues: Iterable<Rhs>

        The right-hand side iterable to compare against

      • cmp: Cmp.t<Comparable>

        Comparison function to determine element equality and order

      • options: {
            comparableLhs?: (lhs: Lhs) => Comparable;
            comparableRhs?: (rhs: Rhs) => Comparable;
            direction?: Cmp.R;
            sortLhs?: boolean;
            sortRhs?: boolean;
        } = {}

        Configuration options

        • OptionalcomparableLhs?: (lhs: Lhs) => Comparable

          Function to convert left values to comparable type

        • OptionalcomparableRhs?: (rhs: Rhs) => Comparable

          Function to convert right values to comparable type

        • Optionaldirection?: Cmp.R

          Comparison direction (ascending or descending)

        • OptionalsortLhs?: boolean

          Whether to sort the left-hand side values

        • OptionalsortRhs?: boolean

          Whether to sort the right-hand side values

      Returns (lhsValues: Iterable<Lhs>) => Generator<[lhs: Lhs, rhs: Rhs]>

      A function that takes an iterable and yields pairs of differences

      Pairs [lhs, rhs] where:

      • [value, undefined] indicates an element in lhs but not in rhs
      • [undefined, value] indicates an element in rhs but not in lhs
      • [lhsValue, rhsValue] indicates differing elements
      // Compare two arrays
      const differences = [...diff([4, 5, 6], Cmp.number)([1, 2, 3])]
      // Result: [[1, undefined], [2, undefined], [3, undefined], [undefined, 4], [undefined, 5], [undefined, 6]]