(content: string)
| 17 | * sha256 and collision-resistant enough for diff detection (not crypto-safe). |
| 18 | */ |
| 19 | export function hashContent(content: string): string { |
| 20 | if (typeof Bun !== 'undefined') { |
| 21 | return Bun.hash(content).toString() |
| 22 | } |
| 23 | // eslint-disable-next-line @typescript-eslint/no-require-imports |
| 24 | const crypto = require('crypto') as typeof import('crypto') |
| 25 | return crypto.createHash('sha256').update(content).digest('hex') |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Hash two strings without allocating a concatenated temp string. Bun path |
no test coverage detected