Function diff

  • Renders the differences between the actual and expected values.

    Type Parameters

    • T

      The type of elements in the arrays.

    Parameters

    • A: T[]

      Actual value

    • B: T[]

      Expected value

    Returns DiffResult<T>[]

    An array of differences between the actual and expected values.

    import { diff } from "@std/internal/diff";
    import { assertEquals } from "@std/assert";

    const a = [1, 2, 3];
    const b = [1, 2, 4];

    assertEquals(diff(a, b), [
    { type: "common", value: 1 },
    { type: "common", value: 2 },
    { type: "removed", value: 3 },
    { type: "added", value: 4 },
    ]);