mirror: A fast canonicalisation utility for stable object equality
0

Configure Feed

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

chore: gold on the `toString`

Marais Rossouw (Jun 29, 2023, 5:34 PM +1000) a73d4c97 60f32b73

+7 -7
+5 -5
readme.md
··· 49 49 50 50 ## 💨 Benchmark 51 51 52 - > via the [`/bench`](/bench) directory with Node v16.20.0 (Apple M1 Pro) 52 + > via the [`/bench`](/bench) directory with Node v18.16.1 (Apple M1 Pro) 53 53 54 54 ``` 55 - ✔ object-identity ~ 56,929,524 ops/sec ± 0.08% 56 - ✔ object-hash ~ 114,195 ops/sec ± 0.01% 57 - ✔ object-identity :: hashed ~ 46,224,968 ops/sec ± 0.03% 58 - ✔ object-hash :: hashed ~ 52,104 ops/sec ± 0.01% 55 + ✔ object-identity ~ 53,216,325 ops/sec ± 0.34% 56 + ✔ object-hash ~ 110,440 ops/sec ± 0.01% 57 + ✔ object-identity :: hashed ~ 45,415,100 ops/sec ± 0.05% 58 + ✔ object-hash :: hashed ~ 51,365 ops/sec ± 0.01% 59 59 ``` 60 60 61 61 > ^ `object-identity` is not as feature-full it's alternatives, specifically around `function` values and other node
+2 -2
src/index.ts
··· 1 1 let seen = new WeakMap<object, string>(); 2 2 3 3 function walk(input: any, ref_index: number) { 4 + if (input == null || typeof input !== 'object') return String(input); 5 + 4 6 let tmp: any; 5 7 let out = ''; 6 8 let i = 0; 7 9 let type = Object.prototype.toString.call(input); 8 - 9 - if (input == null || typeof input !== 'object') return String(input); 10 10 if ( 11 11 !(type === '[object RegExp]' || type === '[object Date]') && 12 12 seen.has(input)