also looking at this
chore(deps): update all non-major dependencies
#2997
29 files
+1047
-444
| @@ -0,0 +1,19 @@ | ||
| 1 | /** | |
| 2 | * Fast hash function for content comparison. | |
| 3 | * This module is intentionally TS-free to keep the hot path lightweight. | |
| 4 | */ | |
| 5 | ||
| 6 | const hasBunHash = typeof globalThis.Bun?.hash === 'function' | |
| 7 | ||
| 8 | export function hashContent(content: string): number | bigint { | |
| 9 | if (hasBunHash) { | |
| 10 | return Bun.hash(content) | |
| 11 | } | |
| 12 | let hash = 0 | |
| 13 | for (let i = 0; i < content.length; i++) { | |
| 14 | const char = content.charCodeAt(i) | |
| 15 | hash = ((hash << 5) - hash) + char | |
| 16 | hash = hash & hash | |
| 17 | } | |
| 18 | return hash | |
| 19 | } | |