Skip to content

Simple and fast equality checker for Node environments

Notifications You must be signed in to change notification settings

bacloud23/Equalz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Equalz

Simple and fast equality checker for Node environments.

It is work in progress, use with your own risks.

Examples:

literal

expect(equalz(5, 5)).toBe(true);

same reference

const o = {};
expect(equalz(o, o)).toBe(true);

non standard

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);

different standards

const a = new String();
const b = new Date();
expect(equalz(a, b)).toBe(false);

array

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);

object

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);

dates

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);

deep object

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);

Benchmarks

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.

Benchmarks

Author

yanna92yar [{at}] gmail {[dot]} com

License

MIT

About

Simple and fast equality checker for Node environments

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published