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: move files into lib

Marais Rossouw (Sep 5, 2024, 1:42 PM +1000) 4069101d 16be744b

+53 -188
-1
bench/deno.json
··· 1 - {}
-138
bench/deno.lock
··· 1 - { 2 - "version": "3", 3 - "packages": { 4 - "specifiers": { 5 - "npm:@marais/bench": "npm:@marais/bench@0.0.8", 6 - "npm:json-stable-stringify": "npm:json-stable-stringify@1.1.1", 7 - "npm:object-hash": "npm:object-hash@3.0.0", 8 - "npm:tiny-stable-stringify": "npm:tiny-stable-stringify@0.1.3" 9 - }, 10 - "npm": { 11 - "@marais/bench@0.0.8": { 12 - "integrity": "sha512-DZ3TqK1eUN77E2nV2Aj2aady61rveJGqGAPNQglzoJL001HJq9elFLRS6pw25e6geIEmRld9cJ5F/EHFUYa+DQ==", 13 - "dependencies": { 14 - "@thi.ng/bench": "@thi.ng/bench@3.5.1" 15 - } 16 - }, 17 - "@thi.ng/api@8.9.31": { 18 - "integrity": "sha512-YuodNQ4TnxV8OIa8xiF9JQ+vBam16W3Z9EbTAAgX/VlQUQ7NEVBbFO8eNGcpyrfOoWdSX4b9JcPbAXuB1dfg1g==", 19 - "dependencies": {} 20 - }, 21 - "@thi.ng/bench@3.5.1": { 22 - "integrity": "sha512-ekueeRFmWdXiCB9vnZxzOXKJ9s6ol3injV79hHZXrL+XqjPiP9VyX4fnVvQ/vTCzR27+wYM8fbz3S1veUEF84w==", 23 - "dependencies": { 24 - "@thi.ng/api": "@thi.ng/api@8.9.31" 25 - } 26 - }, 27 - "call-bind@1.0.7": { 28 - "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", 29 - "dependencies": { 30 - "es-define-property": "es-define-property@1.0.0", 31 - "es-errors": "es-errors@1.3.0", 32 - "function-bind": "function-bind@1.1.2", 33 - "get-intrinsic": "get-intrinsic@1.2.4", 34 - "set-function-length": "set-function-length@1.2.2" 35 - } 36 - }, 37 - "define-data-property@1.1.4": { 38 - "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", 39 - "dependencies": { 40 - "es-define-property": "es-define-property@1.0.0", 41 - "es-errors": "es-errors@1.3.0", 42 - "gopd": "gopd@1.0.1" 43 - } 44 - }, 45 - "es-define-property@1.0.0": { 46 - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", 47 - "dependencies": { 48 - "get-intrinsic": "get-intrinsic@1.2.4" 49 - } 50 - }, 51 - "es-errors@1.3.0": { 52 - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", 53 - "dependencies": {} 54 - }, 55 - "function-bind@1.1.2": { 56 - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", 57 - "dependencies": {} 58 - }, 59 - "get-intrinsic@1.2.4": { 60 - "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", 61 - "dependencies": { 62 - "es-errors": "es-errors@1.3.0", 63 - "function-bind": "function-bind@1.1.2", 64 - "has-proto": "has-proto@1.0.3", 65 - "has-symbols": "has-symbols@1.0.3", 66 - "hasown": "hasown@2.0.2" 67 - } 68 - }, 69 - "gopd@1.0.1": { 70 - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", 71 - "dependencies": { 72 - "get-intrinsic": "get-intrinsic@1.2.4" 73 - } 74 - }, 75 - "has-property-descriptors@1.0.2": { 76 - "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", 77 - "dependencies": { 78 - "es-define-property": "es-define-property@1.0.0" 79 - } 80 - }, 81 - "has-proto@1.0.3": { 82 - "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", 83 - "dependencies": {} 84 - }, 85 - "has-symbols@1.0.3": { 86 - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", 87 - "dependencies": {} 88 - }, 89 - "hasown@2.0.2": { 90 - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", 91 - "dependencies": { 92 - "function-bind": "function-bind@1.1.2" 93 - } 94 - }, 95 - "isarray@2.0.5": { 96 - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", 97 - "dependencies": {} 98 - }, 99 - "json-stable-stringify@1.1.1": { 100 - "integrity": "sha512-SU/971Kt5qVQfJpyDveVhQ/vya+5hvrjClFOcr8c0Fq5aODJjMwutrOfCU+eCnVD5gpx1Q3fEqkyom77zH1iIg==", 101 - "dependencies": { 102 - "call-bind": "call-bind@1.0.7", 103 - "isarray": "isarray@2.0.5", 104 - "jsonify": "jsonify@0.0.1", 105 - "object-keys": "object-keys@1.1.1" 106 - } 107 - }, 108 - "jsonify@0.0.1": { 109 - "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", 110 - "dependencies": {} 111 - }, 112 - "object-hash@3.0.0": { 113 - "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", 114 - "dependencies": {} 115 - }, 116 - "object-keys@1.1.1": { 117 - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", 118 - "dependencies": {} 119 - }, 120 - "set-function-length@1.2.2": { 121 - "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", 122 - "dependencies": { 123 - "define-data-property": "define-data-property@1.1.4", 124 - "es-errors": "es-errors@1.3.0", 125 - "function-bind": "function-bind@1.1.2", 126 - "get-intrinsic": "get-intrinsic@1.2.4", 127 - "gopd": "gopd@1.0.1", 128 - "has-property-descriptors": "has-property-descriptors@1.0.2" 129 - } 130 - }, 131 - "tiny-stable-stringify@0.1.3": { 132 - "integrity": "sha512-dkqJwMg6uHTlmXREDkvIkHtbgwKpTZ6cfcZSH1rXJEFhH8lhS6pvZk+mUbHXE6LLLyte4X6EGjaFj+pfBmPlcA==", 133 - "dependencies": {} 134 - } 135 - } 136 - }, 137 - "remote": {} 138 - }
-43
bench/index.ts
··· 1 - import { suite } from 'npm:@marais/bench'; 2 - 3 - import objectHash from 'npm:object-hash'; 4 - import jsonStableStringify from 'npm:json-stable-stringify'; 5 - import { stringify as tinyStableStringify } from 'npm:tiny-stable-stringify'; 6 - 7 - import { identify } from '../mod.ts'; 8 - 9 - const getObject = () => { 10 - const c = [1]; 11 - // @ts-expect-error circular 12 - c.push(c); 13 - return { 14 - a: { b: ['c', new Set(['d', new Map([['e', 'f']]), c, 'g'])] }, 15 - d: new Date(), 16 - r: /a/, 17 - }; 18 - }; 19 - 20 - suite<unknown>( 21 - { 22 - 'object-identity'() { 23 - return () => identify(getObject()); 24 - }, 25 - 'object-hash'() { 26 - const options = { algorithm: 'passthrough', unorderedSets: false }; 27 - return () => objectHash(getObject(), options); 28 - }, 29 - 'json-stable-stringify'() { 30 - return () => jsonStableStringify(getObject()); 31 - }, 32 - 'tiny-stable-stringify'() { 33 - return () => tinyStableStringify(getObject()); 34 - }, 35 - }, 36 - (run) => { 37 - run(undefined); 38 - }, 39 - { 40 - size: 50, 41 - iter: 10_000, 42 - }, 43 - );
+6 -5
deno.json
··· 1 1 { 2 2 "version": "0.1.2", 3 3 "name": "@mr/object-identity", 4 - "exports": "./mod.ts", 4 + "exports": "./lib/mod.ts", 5 5 "tasks": { 6 6 "build": "deno run -A scripts/build.ts" 7 7 }, 8 8 "imports": { 9 - "@deno/dnt": "jsr:@deno/dnt@^0.41.0", 10 - "@std/assert": "jsr:@std/assert@^0.221.0" 9 + "@std/assert": "jsr:@std/assert@^1", 10 + "@std/path": "jsr:@std/path@^1" 11 11 }, 12 12 "lock": false, 13 13 "lint": { ··· 28 28 "useTabs": true 29 29 }, 30 30 "exclude": [ 31 - "npm" 31 + "npm", 32 + "coverage" 32 33 ], 33 34 "publish": { 34 35 "include": [ 35 - "mod.ts", 36 + "lib/mod.ts", 36 37 "license", 37 38 "readme.md" 38 39 ]
+46
lib/mod.bench.ts
··· 1 + import objectHash from 'npm:object-hash'; 2 + import jsonStableStringify from 'npm:json-stable-stringify'; 3 + import { stringify as tinyStableStringify } from 'npm:tiny-stable-stringify'; 4 + 5 + import { identify } from './mod.ts'; 6 + 7 + const getObject = () => { 8 + const c = [1]; 9 + // @ts-expect-error circular 10 + c.push(c); 11 + return { 12 + a: { b: ['c', new Set(['d', new Map([['e', 'f']]), c, 'g'])] }, 13 + d: new Date(), 14 + r: /a/, 15 + }; 16 + }; 17 + 18 + Deno.bench({ 19 + name: 'object-identity', 20 + baseline: true, 21 + fn() { 22 + let _ = identify(getObject()); 23 + }, 24 + }); 25 + 26 + Deno.bench({ 27 + name: 'object-hash', 28 + fn() { 29 + const options = { algorithm: 'passthrough', unorderedSets: false }; 30 + let _ = objectHash(getObject(), options); 31 + }, 32 + }); 33 + 34 + Deno.bench({ 35 + name: 'json-stable-stringify', 36 + fn() { 37 + let _ = jsonStableStringify(getObject()); 38 + }, 39 + }); 40 + 41 + Deno.bench({ 42 + name: 'tiny-stable-stringify', 43 + fn() { 44 + let _ = tinyStableStringify(getObject()); 45 + }, 46 + });
+1 -1
mod.test.ts lib/mod.test.ts
··· 5 5 assertNotEquals, 6 6 assertNotMatch, 7 7 } from '@std/assert'; 8 - import { identify } from './mod.ts'; 8 + import { identify } from '../lib/mod.ts'; 9 9 10 10 Deno.test('exports', () => { 11 11 assertInstanceOf(identify, Function);
mod.ts lib/mod.ts