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: edit formating

Marais Rossouw (Jun 28, 2023, 6:01 PM +1000) 60f32b73 e12a38fa

+135 -117
+8 -4
.editorconfig
··· 1 + # http://editorconfig.org 1 2 root = true 2 3 3 4 [*] 4 - charset = utf-8 5 - end_of_line = lf 6 - indent_style = tab 7 5 indent_size = 4 8 - insert_final_newline = true 6 + indent_style = tab 7 + end_of_line = lf 8 + charset = utf-8 9 9 trim_trailing_whitespace = true 10 + insert_final_newline = true 11 + 12 + [*.{json,yml,yaml,md}] 13 + indent_style = space
+2 -1
bench/index.js
··· 27 27 }, 28 28 29 29 ['object-identity :: hashed']() { 30 - const hasher = (val) => createHash('sha1').update(val).digest('hex'); 30 + const hasher = (val) => 31 + createHash('sha1').update(val).digest('hex'); 31 32 32 33 return (o) => identify(o, hasher); 33 34 },
+6 -6
bench/package.json
··· 1 1 { 2 - "type": "module", 3 - "dependencies": { 4 - "@marais/bench": "0.0.8", 5 - "object-hash": "^3.0.0", 6 - "object-identity": "file:.." 7 - } 2 + "type": "module", 3 + "dependencies": { 4 + "@marais/bench": "0.0.8", 5 + "object-hash": "^3.0.0", 6 + "object-identity": "file:.." 7 + } 8 8 }
+38 -46
bench/pnpm-lock.yaml
··· 1 1 lockfileVersion: '6.0' 2 2 3 3 settings: 4 - autoInstallPeers: true 5 - excludeLinksFromLockfile: false 4 + autoInstallPeers: true 5 + excludeLinksFromLockfile: false 6 6 7 7 dependencies: 8 - '@marais/bench': 9 - specifier: 0.0.8 10 - version: 0.0.8 11 - object-hash: 12 - specifier: ^3.0.0 13 - version: 3.0.0 14 - object-identity: 15 - specifier: file:.. 16 - version: file:.. 8 + '@marais/bench': 9 + specifier: 0.0.8 10 + version: 0.0.8 11 + object-hash: 12 + specifier: ^3.0.0 13 + version: 3.0.0 14 + object-identity: 15 + specifier: file:.. 16 + version: file:.. 17 17 18 18 packages: 19 - /@marais/bench@0.0.8: 20 - resolution: 21 - { 22 - integrity: sha512-DZ3TqK1eUN77E2nV2Aj2aady61rveJGqGAPNQglzoJL001HJq9elFLRS6pw25e6geIEmRld9cJ5F/EHFUYa+DQ==, 23 - } 24 - dependencies: 25 - '@thi.ng/bench': 3.4.0 26 - dev: false 19 + /@marais/bench@0.0.8: 20 + resolution: 21 + { integrity: sha512-DZ3TqK1eUN77E2nV2Aj2aady61rveJGqGAPNQglzoJL001HJq9elFLRS6pw25e6geIEmRld9cJ5F/EHFUYa+DQ== } 22 + dependencies: 23 + '@thi.ng/bench': 3.4.0 24 + dev: false 27 25 28 - /@thi.ng/api@8.8.2: 29 - resolution: 30 - { 31 - integrity: sha512-kJCBKhHEYv/gSnbrCGnEgoAX/9bRmVSttQ0GVqQIdJlW3IFlgtz3kz357zcYNQ8mB6cY87e0XxJY3VdbYsgiyQ==, 32 - } 33 - engines: { node: '>=12.7' } 34 - dev: false 26 + /@thi.ng/api@8.8.2: 27 + resolution: 28 + { integrity: sha512-kJCBKhHEYv/gSnbrCGnEgoAX/9bRmVSttQ0GVqQIdJlW3IFlgtz3kz357zcYNQ8mB6cY87e0XxJY3VdbYsgiyQ== } 29 + engines: { node: '>=12.7' } 30 + dev: false 35 31 36 - /@thi.ng/bench@3.4.0: 37 - resolution: 38 - { 39 - integrity: sha512-eY28lsU/7mxV2KrPebo5DTKMDslWDNTcKNNomNcJMKfdDSPmb5Mb7InqekPuv8K2iAC1EVghFBHCi/lIO22qFg==, 40 - } 41 - engines: { node: '>=12.7' } 42 - dependencies: 43 - '@thi.ng/api': 8.8.2 44 - dev: false 32 + /@thi.ng/bench@3.4.0: 33 + resolution: 34 + { integrity: sha512-eY28lsU/7mxV2KrPebo5DTKMDslWDNTcKNNomNcJMKfdDSPmb5Mb7InqekPuv8K2iAC1EVghFBHCi/lIO22qFg== } 35 + engines: { node: '>=12.7' } 36 + dependencies: 37 + '@thi.ng/api': 8.8.2 38 + dev: false 45 39 46 - /object-hash@3.0.0: 47 - resolution: 48 - { 49 - integrity: sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==, 50 - } 51 - engines: { node: '>= 6' } 52 - dev: false 40 + /object-hash@3.0.0: 41 + resolution: 42 + { integrity: sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw== } 43 + engines: { node: '>= 6' } 44 + dev: false 53 45 54 - file:..: 55 - resolution: { directory: .., type: directory } 56 - name: object-identity 57 - dev: false 46 + file:..: 47 + resolution: { directory: .., type: directory } 48 + name: object-identity 49 + dev: false
+41 -41
package.json
··· 1 1 { 2 - "name": "object-identity", 3 - "version": "0.1.1", 4 - "repository": "maraisr/object-identity", 5 - "license": "MIT", 6 - "author": "Marais Rossow <me@marais.dev> (https://marais.io)", 7 - "sideEffects": false, 8 - "exports": { 9 - ".": { 10 - "types": "./index.d.ts", 11 - "import": "./index.mjs", 12 - "require": "./index.js" 13 - }, 14 - "./package.json": "./package.json" 15 - }, 16 - "main": "index.js", 17 - "module": "index.mjs", 18 - "types": "index.d.ts", 19 - "files": [ 20 - "index.js", 21 - "index.mjs", 22 - "index.d.ts" 23 - ], 24 - "scripts": { 25 - "bench": "node bench/index.js", 26 - "build": "bundt --minify", 27 - "format": "prettier --write .", 28 - "test": "uvu src \".test.ts$\" -r tsm", 29 - "typecheck": "tsc --noEmit" 30 - }, 31 - "prettier": "@marais/prettier", 32 - "devDependencies": { 33 - "@marais/prettier": "0.0.2", 34 - "@marais/tsconfig": "0.0.4", 35 - "bundt": "2.0.0-next.5", 36 - "tsm": "2.3.0", 37 - "typescript": "5.1.3", 38 - "uvu": "0.5.4" 39 - }, 40 - "volta": { 41 - "node": "18.16.1" 42 - } 2 + "name": "object-identity", 3 + "version": "0.1.1", 4 + "repository": "maraisr/object-identity", 5 + "license": "MIT", 6 + "author": "Marais Rossow <me@marais.dev> (https://marais.io)", 7 + "sideEffects": false, 8 + "exports": { 9 + ".": { 10 + "types": "./index.d.ts", 11 + "import": "./index.mjs", 12 + "require": "./index.js" 13 + }, 14 + "./package.json": "./package.json" 15 + }, 16 + "main": "index.js", 17 + "module": "index.mjs", 18 + "types": "index.d.ts", 19 + "files": [ 20 + "index.js", 21 + "index.mjs", 22 + "index.d.ts" 23 + ], 24 + "scripts": { 25 + "bench": "node bench/index.js", 26 + "build": "bundt --minify", 27 + "format": "prettier --write .", 28 + "test": "uvu src \".test.ts$\" -r tsm", 29 + "typecheck": "tsc --noEmit" 30 + }, 31 + "prettier": "@marais/prettier", 32 + "devDependencies": { 33 + "@marais/prettier": "0.0.4", 34 + "@marais/tsconfig": "0.0.4", 35 + "bundt": "2.0.0-next.5", 36 + "tsm": "2.3.0", 37 + "typescript": "5.1.3", 38 + "uvu": "0.5.4" 39 + }, 40 + "volta": { 41 + "node": "18.16.1" 42 + } 43 43 }
+4 -4
pnpm-lock.yaml
··· 6 6 7 7 devDependencies: 8 8 '@marais/prettier': 9 - specifier: 0.0.2 10 - version: 0.0.2 9 + specifier: 0.0.4 10 + version: 0.0.4 11 11 '@marais/tsconfig': 12 12 specifier: 0.0.4 13 13 version: 0.0.4 ··· 94 94 '@jridgewell/sourcemap-codec': 1.4.14 95 95 dev: true 96 96 97 - /@marais/prettier@0.0.2: 98 - resolution: {integrity: sha512-gvPOevtXqyf/YYrneZghtNBtMGrB855EOSeXxgd+tdnpNT0Q+9QaooJHMx2SPrtSUx1tMJXrjW0XB1eiM4aBUA==} 97 + /@marais/prettier@0.0.4: 98 + resolution: {integrity: sha512-fcJgHALkAkmOyMEioqMaikXlUQLy9jj+SZjlI2AD9V0vEO1EjR3ZI5vz3y6A0Bz/PgskbyM9+F/A44850UWrhQ==} 99 99 dev: true 100 100 101 101 /@marais/tsconfig@0.0.4:
+13 -3
src/index.test.ts
··· 59 59 }); 60 60 61 61 Objects('key ordering', () => { 62 - assert.equal(identify({ one: 'one', two: 'two' }), identify({ two: 'two', one: 'one' })); 62 + assert.equal( 63 + identify({ one: 'one', two: 'two' }), 64 + identify({ two: 'two', one: 'one' }), 65 + ); 63 66 }); 64 67 65 68 Objects('complex keys', () => { ··· 129 132 const Sets = suite('set'); 130 133 131 134 Sets('shouldnt be ordered', () => { 132 - assert.not.equal(identify(new Set([1, 2, 3])), identify(new Set([3, 2, 1]))); 135 + assert.not.equal( 136 + identify(new Set([1, 2, 3])), 137 + identify(new Set([3, 2, 1])), 138 + ); 133 139 }); 134 140 135 141 Sets('shouldnt be ordered', () => { ··· 185 191 186 192 Values('primitives', () => { 187 193 const t = (v: any) => 188 - assert.equal(identify(v), identify(v), `Value ${v} should have hashed correctly.`); 194 + assert.equal( 195 + identify(v), 196 + identify(v), 197 + `Value ${v} should have hashed correctly.`, 198 + ); 189 199 190 200 t('test'); 191 201 t(new Date());
+14 -3
src/index.ts
··· 7 7 let type = Object.prototype.toString.call(input); 8 8 9 9 if (input == null || typeof input !== 'object') return String(input); 10 - if (!(type === '[object RegExp]' || type === '[object Date]') && seen.has(input)) 10 + if ( 11 + !(type === '[object RegExp]' || type === '[object Date]') && 12 + seen.has(input) 13 + ) 11 14 return seen.get(input)!; 12 15 seen.set(input, '~' + ++ref_index); 13 16 ··· 26 29 { 27 30 out += 'o'; 28 31 tmp = Object.keys(input).sort(); 29 - for (; i < tmp.length; out += tmp[i] + walk(input[tmp[i++]], ref_index)); 32 + for ( 33 + ; 34 + i < tmp.length; 35 + out += tmp[i] + walk(input[tmp[i++]], ref_index) 36 + ); 30 37 } 31 38 break; 32 39 ··· 34 41 { 35 42 out += 'o'; 36 43 tmp = Array.from((input as Map<string, unknown>).keys()).sort(); 37 - for (; i < tmp.length; out += tmp[i] + walk(input.get(tmp[i++]), ref_index)); 44 + for ( 45 + ; 46 + i < tmp.length; 47 + out += tmp[i] + walk(input.get(tmp[i++]), ref_index) 48 + ); 38 49 } 39 50 break; 40 51
+9 -9
tsconfig.json
··· 1 1 { 2 - "extends": "@marais/tsconfig", 3 - "compilerOptions": { 4 - "baseUrl": ".", 5 - "paths": { 6 - "object-identity": ["src/index.d.ts"] 7 - } 8 - }, 9 - "include": ["src", "test"], 10 - "exclude": ["node_modules"] 2 + "extends": "@marais/tsconfig", 3 + "compilerOptions": { 4 + "baseUrl": ".", 5 + "paths": { 6 + "object-identity": ["src/index.d.ts"] 7 + } 8 + }, 9 + "include": ["src", "test"], 10 + "exclude": ["node_modules"] 11 11 }