Socket
Socket
Sign inDemoInstall

object-identity

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    object-identity


Version published
Weekly downloads
330
decreased by-49.54%
Maintainers
1
Install size
5.54 kB
Created
Weekly downloads
 

Readme

Source

object-identity



npm add object-identity hashes objects

downloads size size

⚡ 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

FAQs

Last updated on 29 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc