getObjectDiff

Compares two objects and returns a diff for each value and its possible subvalues. Supports deeply nested objects of any value type.

IMPORT

import { getObjectDiff } from "@donedeal0/superdiff";

FORMAT

Input

prevData: Record<string, unknown>;
nextData: Record<string, unknown>;
options?: {
  ignoreArrayOrder?: boolean, // false by default,
  showOnly?: {
    statuses: ("added" | "deleted" | "updated" | "equal")[], // [] by default
    granularity?: "basic" | "deep" // "basic" by default
  }
}
  • prevData: the original object.

  • nextData: the new object.

  • options

    • ignoreArrayOrder: if set to true, ["hello", "world"] and ["world", "hello"] will be treated as equal, because the two arrays contain the same values, just in a different order.

    • showOnly: returns only the values whose status you are interested in. It takes two parameters:

      • statuses: status you want to see in the output (e.g. ["added", "equal"])

        • granularity:

          • basic returns only the main properties whose status matches your query.

          • deep can return main properties if some of their subproperties' status match your request. The subproperties are filtered accordingly.

Output


USAGE

Input

Output

Last updated