jsoncmp
Version:
Fast and type-safe deep comparison for JSON-compatible data.
2 lines (1 loc) • 1.1 kB
JavaScript
const{keys:t,prototype:{hasOwnProperty:e}}=Object,r="object"==typeof process,o=("object"==typeof window||"object"==typeof self)&&"object"==typeof navigator&&"string"==typeof navigator.userAgent,n="object"===globalThis.chrome||o&&navigator.userAgent.search(/chrome/i)>-1||r&&void 0!==process.versions?.v8&&"object"!=typeof Bun,s=void 0!==globalThis.$?.IsHTMLDDA||o&&null!==navigator.userAgent.match(/^(?!.*(chrome|crios)).*safari/i)||r&&void 0!==process.versions?.webkit;function i(r,o){if(null===r||null===o||"object"!=typeof r||"object"!=typeof o)return r===o;const c=Array.isArray(r),f=Array.isArray(o);if(c&&f){const t=r.length;if(t!==o.length)return!1;for(let e=t-1;e>=0;e--){const t=r[e],n=o[e];if(t!==n&&!i(t,n))return!1}return!0}if(!c&&!f){const c=t(r),f=c.length;if(f!==t(o).length)return!1;if(n&&f>1&&f<20||s&&f<66)for(const t in r){const n=o[t];if(void 0===n&&!e.call(o,t))return!1;const s=r[t];if(s!==n&&!i(s,n))return!1}else for(let t=f-1;t>=0;t--){const n=c[t],s=o[n];if(void 0===s&&!e.call(o,n))return!1;const f=r[n];if(f!==s&&!i(f,s))return!1}return!0}return!1}export{i as default};