- .github
- bench
- scripts
- .editorconfig216 B
- .gitignore39 B
- deno.json523 B
- deno.lock14 KB
- license1.1 KB
- mod.test.ts4.9 KB
- mod.ts1.6 KB
- readme.md1.9 KB
readme.md
object-identity 
A utility that provides a stable identity of an object
This is free to use software, but if you do like it, consider supporting me ❤️
⚡ Features
- ✅ Intuitive
- 🌪 Recursive/Circular support
- 🏎 Performant — check the benchmarks.
- 🪶 Lightweight — a mere 387B and no dependencies.
🚀 Usage
import { identify } from 'object-identity';
// or
import { identify } from 'https://deno.land/x/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 deno 1.41.3
✔ object-identity ~ 14,646,170 ops/sec ± 0.10%
✔ object-hash ~ 144,060 ops/sec ± 0.01%
✔ json-stable-stringify ~ 638,559 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