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: speak to this being a canonicalizing lib

Marais Rossouw (Jun 24, 2026, 12:09 PM +1000) cca77846 e4ea2ad7

+25 -12
+12 -1
package.json
··· 1 1 { 2 2 "name": "object-identity", 3 3 "version": "0.1.2", 4 + "description": "Canonicalize any value into a tiny, stable identity string. Structural fingerprints for cache keys, deduping, and memoization.", 4 5 "repository": "maraisr/object-identity", 5 6 "license": "MIT", 6 7 "author": "Marais Rossouw <me@marais.dev> (https://marais.io)", 7 8 "keywords": [ 9 + "canonical", 10 + "canonicalize", 8 11 "object", 9 12 "identity", 13 + "fingerprint", 10 14 "hash", 11 - "fingerprint" 15 + "stable", 16 + "deterministic", 17 + "structural", 18 + "equality", 19 + "dedupe", 20 + "memoize", 21 + "cache-key", 22 + "normalize" 12 23 ], 13 24 "sideEffects": false, 14 25 "exports": {
+13 -11
readme.md
··· 6 6 7 7 </samp> 8 8 9 - **A utility that provides a stable identity of an object** 9 + **A tiny, fast utility that canonicalizes any value into a stable identity, for structurally 10 + equality.** 10 11 11 12 <br> 12 13 <br> ··· 24 25 25 26 ## ⚡ Features 26 27 27 - - ✅ **Intuitive** 28 - - 🌪 **Recursive/Circular support** 29 - - 🏎 **Performant** — check the [benchmarks](#-benchmark). 30 - - 🪶 **Lightweight** — a mere 387B and no 28 + - 🧬 **Canonical.** The same shape always produces the same id. 29 + - 🌀 **Deep and cycle-safe.** Handles nested objects, arrays, sets, maps, and circular references. 30 + - 🏎 **Fast.** See the [benchmarks](#-benchmark). 31 + - 🪶 **Tiny.** Around 436B minified and gzipped, with zero 31 32 [dependencies](https://npm.anvaka.com/#/view/2d/object-identity/). 32 33 33 34 ## ⚙️ Install ··· 40 41 ```ts 41 42 import { identify } from 'object-identity'; 42 43 43 - // ~> identity the object 44 - const id1 = identify({ a: new Set(['b', 'c', new Map([['d', 'e']])]) }); 45 - // ~> an entirely different object, but structurally the same 46 - const id2 = identify({ a: new Set(['b', 'c', new Map([['e', 'e']])]) }); 44 + // same shape, different key order, same id 45 + identify({ a: 1, b: 2 }) === identify({ b: 2, a: 1 }); // true 47 46 48 - // they should equal 49 - assert.toEqual(hashA, hashB); 47 + // a plain object and an equivalent Map produce the same id 48 + identify({ a: 'b' }) === identify(new Map([['a', 'b']])); // true 49 + 50 + // nesting, Sets, Dates, and RegExps are all supported 51 + const key = identify({ user: 7, filters: new Set(['active', 'new']) }); 50 52 ``` 51 53 52 54 ## 💨 Benchmark