@glyph-cat/equality
Version:
General purpose equality-checking presets.
3 lines (2 loc) • 1.17 kB
JavaScript
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).Equality={})}(this,(function(t){"use strict";function n(t,n){if(Array.isArray(t)&&Array.isArray(n)){if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(!Object.is(t[e],n[e]))return!1;return!0}return Object.is(t,n)}const e=n;function r(t){return"object"==typeof t&&!function(t){return Object.is(t,null)}(t)}function o(t,n){if(r(t)&&r(n)){const e=Object.keys(t),r=Object.keys(n);if(e.length!==r.length)return!1;for(let o=0;o<e.length;o++){const f=e[o],u=r[o];if(f!==u)return!1;if(!Object.is(t[f],n[u]))return!1}return!0}return Object.is(t,n)}const f=o;function u(t,e){const r=Array.isArray(t),f=Array.isArray(e);return r===f&&(r&&f?n(t,e):o(t,e))}const c=u;function i(t,n){return JSON.stringify(t)===JSON.stringify(n)}const s=i;t.arrayOrObjectShallowEqual=u,t.arrayShallowEqual=n,t.objectShallowEqual=o,t.shallowCompareArray=e,t.shallowCompareArrayOrObject=c,t.shallowCompareObject=f,t.stringifyCompare=s,t.stringifyEqual=i}));
//# sourceMappingURL=index.js.map