getListDiff
Compares two arrays and returns a diff for each entry. Supports duplicate values, primitive values and objects.
IMPORT
import { getListDiff } from "@donedeal0/superdiff";FORMAT
Input
prevList: T[];
nextList: T[];
options?: {
showOnly?: ("added" | "deleted" | "moved" | "updated" | "equal")[], // [] by default
referenceProperty?: string, // "" by default
ignoreArrayOrder?: boolean, // false by default,
considerMoveAsUpdate?: boolean // false by default
}prevList: the original list.nextList: the new list.optionsshowOnlygives you the option to return only the values whose status you are interested in (e.g.["added", "equal"]).referencePropertywill consider an object to beupdatedrather thanaddedordeletedif one of its properties remains stable, such as itsid. This option has no effect on other datatypes.ignoreArrayOrder: if set totrue,["hello", "world"]and["world", "hello"]will be treated asequal, because the two arrays contain the same values, just in a different order.considerMoveAsUpdate: if set totrueamovedvalue will be considered asupdated.
Output
USAGE
Input
Output
Last updated