0.1.2 • Published 2 years ago

object-identity v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

object-identity

npm add object-identity hashes objects

⚔ 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 /bench directory with Node v18.16.1 (Apple M1 Pro)

āœ” object-identity           ~ 53,216,325 ops/sec ± 0.34%
āœ” object-hash               ~    110,440 ops/sec ± 0.01%
āœ” object-identity :: hashed ~ 45,415,100 ops/sec ± 0.05%
āœ” object-hash :: hashed     ~     51,365 ops/sec ± 0.01%

^ object-identity is not as feature-full it's alternatives, specifically around function values 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

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.5

2 years ago

0.0.6

2 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

4 years ago