Simple and fast equality checker for Node environments.
It is work in progress, use with your own risks.
expect(equalz(5, 5)).toBe(true);
const o = {};
expect(equalz(o, o)).toBe(true);
const a = Buffer.from("");
const b = Buffer.from("");
expect(equalz(a, b)).toBe(true);
const c = Buffer.from("hello");
const d = Buffer.from("world");
expect(equalz(c, d)).toBe(false);
const a = new String();
const b = new Date();
expect(equalz(a, b)).toBe(false);
const a = [1, 2, 3];
const b = [1, 2, 3];
expect(equalz(a, b)).toBe(true);
const c = [1, 2, 3];
const d = [1, 1, 1];
expect(equalz(c, d)).toBe(false);
const a = {};
const b = {};
expect(equalz(a, b)).toBe(true);
const c = { a: 1 };
const d = { a: 1 };
expect(equalz(c, d)).toBe(true);
const e = { a: 1 };
const f = { a: 1, b: 2 };
expect(equalz(e, f)).toBe(false);
const c = new Date(0);
const d = new Date(9);
expect(equalz(c, d)).toBe(false);
const e = new Date(0);
const f = new Date(0);
expect(equalz(e, f)).toBe(true);
const c = { a: 1, d: { c: 5 } };
const d = { a: 1, d: { c: 5 } };
expect(equalz(c, d)).toBe(true);
const e = { a: 1, d: { c: 5 } };
const f = { a: 1, d: { c: 6 } };
expect(equalz(e, f)).toBe(false);
const g = { a: 1, d: { c: new Date(0) } };
const h = { a: 1, d: { c: new Date(1) } };
expect(equalz(g, h)).toBe(false);
I've run the same benchmarks thanks to fast-equals. It is much more simpler (dumber and more dumb), and a little bit slower; Still it is among the fastests.
yanna92yar [{at}] gmail {[dot]} com
MIT