MCPcopy Create free account
hub / github.com/arktypeio/arktype / hashOf

Function hashOf

ark/util/strings.ts:125–138  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

123
124// cyrb53's two 32-bit lanes, a 64-bit string hash
125export const hashOf = (input: string): string => {
126 let h1 = 0xdeadbeef
127 let h2 = 0x41c6ce57
128 for (let i = 0; i < input.length; i++) {
129 const code = input.charCodeAt(i)
130 h1 = Math.imul(h1 ^ code, 2654435761)
131 h2 = Math.imul(h2 ^ code, 1597334677)
132 }
133 h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507)
134 h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909)
135 h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507)
136 h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909)
137 return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36).padStart(7, "0")
138}
139
140/**
141 * How many insertions, deletions, substitutions and swaps of neighbors turn a

Callers 15

flattenBundleFunction · 0.90
holeNameOfFunction · 0.90
importFoldedFunction · 0.90
writeCachedUnitsMethod · 0.90
readConfigurationMethod · 0.90
foldingOfMethod · 0.90
foldSitesMethod · 0.90
inputExpressionOfMethod · 0.90
siteNameOfFunction · 0.90
oneModuleOfFunction · 0.90
sharedModulesOfFunction · 0.90
withCallsOnceFunction · 0.90

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected