Superdiff provides a complete and readable diff for both arrays and objects. Plus, it supports stream and file inputs for handling large datasets efficiently, is battle-tested, has zero dependencies, and is super fast.
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.

45 lines
927 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";
status: DiffStatus;
2 years ago
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";
status: DiffStatus;
2 years ago
diff: {
property: string;
previousValue: any;
currentValue: any;
status: DiffStatus;
subPropertiesDiff?: Subproperties[];
}[];
};
export type DataDiff = ListDiff | ObjectDiff;