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.

52 lines
1.2 KiB

type DiffStatus = "added" | "equal" | "moved" | "deleted" | "updated";
type ObjectData = Record<string, any> | undefined | null;
type ListData = any;
type Options = {
ignoreArrayOrder?: boolean;
};
type ListDiff = {
type: "list";
status: DiffStatus;
diff: {
value: ListData;
prevIndex: number | null;
newIndex: number | null;
indexDiff: number | null;
status: DiffStatus;
}[];
};
type SubProperties = {
name: string;
previousValue: any;
currentValue: any;
status: DiffStatus;
subDiff?: SubProperties[];
};
type ObjectDiff = {
type: "object";
status: DiffStatus;
diff: {
property: string;
previousValue: any;
currentValue: any;
status: DiffStatus;
subPropertiesDiff?: SubProperties[];
}[];
};
declare function getObjectDiff(
prevData: ObjectData,
nextData: ObjectData,
options?: Options
): ObjectDiff;
declare const getListDiff: (
prevList: ListData[] | undefined | null,
nextList: ListData[] | undefined | null
) => ListDiff;
declare function isEqual(a: any, b: any, options?: Options): boolean;
declare function isObject(value: any): value is Record<string, any>;
export { getListDiff, getObjectDiff, isEqual, isObject };