MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / computeHash

Function computeHash

src/services/api/promptCacheBreakDetection.ts:170–179  ·  view source on GitHub ↗
(data: unknown)

Source from the content-addressed store, hash-verified

168}
169
170function computeHash(data: unknown): number {
171 const str = jsonStringify(data)
172 if (typeof Bun !== 'undefined') {
173 const hash = Bun.hash(str)
174 // Bun.hash can return bigint for large inputs; convert to number safely
175 return typeof hash === 'bigint' ? Number(hash & 0xffffffffn) : hash
176 }
177 // Fallback for non-Bun runtimes (e.g. Node.js via npm global install)
178 return djb2Hash(str)
179}
180
181/** MCP tool names are user-controlled (server config) and may leak filepaths.
182 * Collapse them to 'mcp'; built-in names are a fixed vocabulary. */

Callers 2

computePerToolHashesFunction · 0.85
recordPromptStateFunction · 0.85

Calls 2

jsonStringifyFunction · 0.85
djb2HashFunction · 0.85

Tested by

no test coverage detected