(str: string)
| 5 | * output (e.g. cache directory names that must survive runtime upgrades). |
| 6 | */ |
| 7 | export function djb2Hash(str: string): number { |
| 8 | let hash = 0 |
| 9 | for (let i = 0; i < str.length; i++) { |
| 10 | hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0 |
| 11 | } |
| 12 | return hash |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Hash arbitrary content for change detection. Bun.hash is ~100x faster than |
no outgoing calls
no test coverage detected