array-comparisoncomparisoncomparison-tooldeep-diffdiffjson-diffnodejsobject-comparisonobject-diffobjectdiffobjectdifferencereactstreamingstreaming-datatypescript
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
883 B
43 lines
883 B
2 years ago
|
export const STATUS: Record<string, DiffStatus> = {
|
||
|
ADDED: "added",
|
||
|
EQUAL: "equal",
|
||
|
MOVED: "moved",
|
||
|
DELETED: "deleted",
|
||
|
UPDATED: "updated",
|
||
|
};
|
||
|
|
||
|
export type DiffStatus = "added" | "equal" | "moved" | "deleted" | "updated";
|
||
|
export type ObjectData = Record<string, any> | undefined | null;
|
||
|
export type ListData = any;
|
||
|
|
||
|
export type ListDiff = {
|
||
|
type: "list";
|
||
|
diff: {
|
||
|
value: ListData;
|
||
|
prevIndex: number | null;
|
||
|
newIndex: number | null;
|
||
|
indexDiff: number | null;
|
||
|
status: DiffStatus;
|
||
|
}[];
|
||
|
};
|
||
|
|
||
|
export type Subproperties = {
|
||
|
name: string;
|
||
|
previousValue: any;
|
||
|
currentValue: any;
|
||
|
status: DiffStatus;
|
||
|
};
|
||
|
|
||
|
export type ObjectDiff = {
|
||
|
type: "object";
|
||
|
diff: {
|
||
|
property: string;
|
||
|
previousValue: any;
|
||
|
currentValue: any;
|
||
|
status: DiffStatus;
|
||
|
subPropertiesDiff?: Subproperties[];
|
||
|
}[];
|
||
|
};
|
||
|
|
||
|
export type DataDiff = ListDiff | ObjectDiff;
|