UNPKG

@tempots/std

Version:

Std library for TypeScript. Natural complement to the Tempo libraries.

63 lines (62 loc) 1.64 kB
const O = (e, t) => e === t || e !== e && t !== t, i = (e, t) => { if (O(e, t)) return !0; if (e == null || t == null) return !1; const l = Array.isArray(e), b = Array.isArray(t); if (l !== b) return !1; if (l) { const s = e, n = t, a = s.length; if (a !== n.length) return !1; for (let r = 0; r < a; r++) if (!i(s[r], n[r])) return !1; return !0; } const u = e instanceof Date, I = t instanceof Date; if (u !== I) return !1; if (u) { const s = e, n = t; return +s == +n; } const p = e instanceof Set, g = t instanceof Set; if (p !== g) return !1; if (p) { const s = e, n = t; if (s.size !== n.size) return !1; const a = s.keys(); for (; ; ) { const r = a.next(); if (r.done ?? !1) break; if (!n.has(r.value)) return !1; } return !0; } const h = e instanceof Map, j = t instanceof Map; if (h !== j) return !1; if (h) { const s = e, n = t; if (s.size !== n.size) return !1; const r = s.keys(); for (; ; ) { const o = r.next(); if (o.done ?? !1) break; if (!i(s.get(o.value), n.get(o.value))) return !1; } return !0; } const y = typeof e == "object"; if (y !== (typeof t == "object")) return !1; if (y) { const s = e, n = t, a = Object.keys(s), r = Object.keys(n), o = a.length; if (o !== r.length) return !1; for (let f = 0; f < o; f++) { const c = a[f]; if (!Object.prototype.hasOwnProperty.call(n, c) || !i(s[c], n[c])) return !1; } return !0; } return !1; }, M = (e, t) => e == t; export { i as deepEqual, M as looseEqual, O as strictEqual };