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.
17 lines
508 B
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); |
|
}
|
|
|