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.
 
 

41 lines
828 B

export enum ObjectStatus {
ADDED = "added",
EQUAL = "equal",
DELETED = "deleted",
UPDATED = "updated",
}
export enum Granularity {
BASIC = "basic",
DEEP = "deep",
}
export type ObjectData = Record<string, unknown> | undefined | null;
export type ObjectDiffOptions = {
ignoreArrayOrder?: boolean;
showOnly?: {
statuses: `${ObjectStatus}`[];
granularity?: `${Granularity}`;
};
};
export const DEFAULT_OBJECT_DIFF_OPTIONS = {
ignoreArrayOrder: false,
showOnly: { statuses: [], granularity: Granularity.BASIC },
};
/** recursive diff in case of subproperties */
export type Diff = {
property: string;
previousValue: unknown;
currentValue: unknown;
status: `${ObjectStatus}`;
diff?: Diff[];
};
export type ObjectDiff = {
type: "object";
status: `${ObjectStatus}`;
diff: Diff[];
};