MCPcopy
hub / github.com/vitest-dev/vitest / generateHash

Function generateHash

packages/runner/src/utils/collect.ts:174–185  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

172
173/* @__NO_SIDE_EFFECTS__ */
174export function generateHash(str: string): string {
175 let hash = 0
176 if (str.length === 0) {
177 return `${hash}`
178 }
179 for (let i = 0; i < str.length; i++) {
180 const char = str.charCodeAt(i)
181 hash = (hash << 5) - hash + char
182 hash = hash & hash // Convert to 32bit integer
183 }
184 return `${hash}`
185}
186
187export function calculateSuiteHash(parent: Suite): void {
188 parent.tasks.forEach((t, idx) => {

Callers 4

collectTestsFunction · 0.90
createFailedFileTaskFunction · 0.90
createFileTaskFunction · 0.90
generateFileHashFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected