| 1 | function fileContentRevision(contents: string): string { |
| 2 | let hash = 2_166_136_261; |
| 3 | for (let index = 0; index < contents.length; index += 1) { |
| 4 | hash ^= contents.charCodeAt(index); |
| 5 | hash = Math.imul(hash, 16_777_619); |
| 6 | } |
| 7 | return `${contents.length}:${(hash >>> 0).toString(36)}`; |
| 8 | } |
| 9 | |
| 10 | export function projectFileCacheKey(cwd: string, relativePath: string, contents: string): string { |
| 11 | return `${cwd}:${relativePath}:${fileContentRevision(contents)}`; |
| 12 | } |