- .github
- bench
- src
- .editorconfig145 B
- .gitignore139 B
- .prettierignore10 B
- license1.1 KB
- package.json853 B
- pnpm-lock.yaml19 KB
- readme.md2.0 KB
- tsconfig.json296 B
readme.md
⚡ Features
- ✅ Intuitive
- 🌪 Recursive/Circular support
- 🏎 Performant — check the benchmarks.
- 🪶 Lightweight — a mere 387B and no dependencies.
🚀 Usage
import { identify } from 'object-identity';
// ~> identity the object
const id1 = identify({ a: new Set(['b', 'c', new Map([['d', 'e']])]) });
// ~> an entirely different object, but structurally the same
const id2 = identify({ a: new Set(['b', 'c', new Map([['e', 'e']])]) });
// they should equal
assert.toEqual(hashA, hashB);
💨 Benchmark
via the
/benchdirectory with Node v16.20.0 (Apple M1 Pro)
✔ object-identity ~ 56,929,524 ops/sec ± 0.08%
✔ object-hash ~ 114,195 ops/sec ± 0.01%
✔ object-identity :: hashed ~ 46,224,968 ops/sec ± 0.03%
✔ object-hash :: hashed ~ 52,104 ops/sec ± 0.01%
^
object-identityis not as feature-full it's alternatives, specifically aroundfunctionvalues and other node builtins. So take this benchmark with a grain of salt, as it's only testing "json-like" payloads.
License
MIT © Marais Rossouw