mirror: A fast canonicalisation utility for stable object equality
0

Configure Feed

Select the types of activity you want to include in your feed.

docs: better readme

Marais Rossouw (Sep 5, 2024, 1:42 PM +1000) e2205c79 1a575aa8

+20 -12
+20 -12
readme.md
··· 8 8 9 9 **A utility that provides a stable identity of an object** 10 10 11 + <br> 12 + <br> 13 + 11 14 <sup> 12 15 13 16 This is free to use software, but if you do like it, consider supporting me ❤️ ··· 27 30 - 🪶 **Lightweight** — a mere 387B and no 28 31 [dependencies](https://npm.anvaka.com/#/view/2d/object-identity/). 29 32 30 - ## 🚀 Usage 33 + ## ⚙️ Install 31 34 32 - > Avaliable on [jsr](https://jsr.io/@mr/object-identity), 33 - > [NPM](https://npmjs.com/package/object-identity) and 34 - > [deno.land](https://deno.land/x/object_identity) 35 + - **npm** — available as [`object-identity`](https://www.npmjs.com/package/object-identity) 36 + - **JSR** — available as [`@mr/object-identity`](https://jsr.io/@mr/object-identity) 37 + 38 + ## 🚀 Usage 35 39 36 40 ```ts 37 41 import { identify } from 'object-identity'; 38 - // or 39 - import { identify } from 'https://deno.land/x/object_identity'; 40 42 41 43 // ~> identity the object 42 44 const id1 = identify({ a: new Set(['b', 'c', new Map([['d', 'e']])]) }); ··· 48 50 ``` 49 51 50 52 ## 💨 Benchmark 51 - 52 - > via the [`/bench`](/bench) directory with deno 1.45.2 53 53 54 54 ``` 55 - ✔ object-identity ~ 313,676 ops/sec ± 0.39% 56 - ✔ object-hash ~ 88,873 ops/sec ± 0.16% 57 - ✔ json-stable-stringify ~ 444,839 ops/sec ± 0.41% 58 - ✔ tiny-stable-stringify ~ 520,833 ops/sec ± 0.45% 55 + benchmark time (avg) iter/s (min … max) p75 p99 p995 56 + --------------------------------------------------------------------------- ----------------------------- 57 + object-identity 2.2 µs/iter 453,803.6 (1.99 µs … 2.44 µs) 2.35 µs 2.44 µs 2.44 µs 58 + object-hash 8.76 µs/iter 114,168.3 (7.96 µs … 225.33 µs) 8.71 µs 11.75 µs 14.92 µs 59 + json-stable-stringify 1.77 µs/iter 565,184.5 (1.75 µs … 1.86 µs) 1.77 µs 1.86 µs 1.86 µs 60 + tiny-stable-stringify 1.63 µs/iter 612,009.4 (1.62 µs … 1.68 µs) 1.64 µs 1.68 µs 1.68 µs 61 + 62 + summary 63 + object-identity 64 + 1.35x slower than tiny-stable-stringify 65 + 1.25x slower than json-stable-stringify 66 + 3.97x faster than object-hash 59 67 ``` 60 68 61 69 > ^ `object-identity` is not as feature-full it's alternatives, specifically around `function`