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.
 
 

17 lines
508 B

export function isEqual(a: any, b: any): boolean {
if (typeof a !== typeof b) return false;
if (Array.isArray(a)) {
if (a.length !== b.length) {
return false;
}
return a.every((v, i) => JSON.stringify(v) === JSON.stringify(b[i]));
}
if (typeof a === "object") {
return JSON.stringify(a) === JSON.stringify(b);
}
return a === b;
}
export function isObject(value: any): value is Record<string, any> {
return !!value && typeof value === "object" && !Array.isArray(value);
}