Vanessa 2023-04-28 22:08:57 +08:00
parent 0cd68fe571
commit e94a534b02
9 changed files with 111 additions and 114 deletions

View file

@ -46,3 +46,13 @@ export const isFileAnnotation = (text: string) => {
export const looseJsonParse = (text: string) => {
return Function(`"use strict";return (${text})`)();
};
export const objEquals = (a: any, b: any): boolean => {
if (a === b) return true;
if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();
if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) return a === b;
if (a.prototype !== b.prototype) return false;
const keys = Object.keys(a);
if (keys.length !== Object.keys(b).length) return false;
return keys.every(k => objEquals(a[k], b[k]));
};