https://github.com/bacloud22/equalz
Simple and fast equality checker for Node environments
https://github.com/bacloud22/equalz
equals javascript nodejs
Last synced: 2 months ago
JSON representation
Simple and fast equality checker for Node environments
- Host: GitHub
- URL: https://github.com/bacloud22/equalz
- Owner: bacloud22
- Created: 2024-01-20T20:59:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-20T21:05:54.000Z (over 1 year ago)
- Last Synced: 2025-01-10T06:59:42.407Z (4 months ago)
- Topics: equals, javascript, nodejs
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Equalz
Simple and fast equality checker for Node environments.
_It is work in progress, use with your own risks._
## Examples:
### literal
```js
expect(equalz(5, 5)).toBe(true);
```### same reference
```js
const o = {};
expect(equalz(o, o)).toBe(true);
```### non standard
```js
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
```js
const a = new String();
const b = new Date();
expect(equalz(a, b)).toBe(false);
```### array
```js
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
```js
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
```js
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
```js
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](https://github.com/planttheidea/fast-equals). It is much more simpler (dumber and more dumb), and a little bit slower; Still it is among the fastests.
[Benchmarks](./BENCHMARKS.txt)
## Author
yanna92yar [{at}] gmail {[dot]} com
## License
MIT