* Computes the sha1 digest of a file by streaming it, so files too large to fit * in a single Buffer (see MAX_BUFFER_FILE_SIZE) can still be hashed.
(path: string)
| 38 | * in a single Buffer (see {@link MAX_BUFFER_FILE_SIZE}) can still be hashed. |
| 39 | */ |
| 40 | async function hashFile(path: string): Promise<string> { |
| 41 | const digest = createHash('sha1'); |
| 42 | for await (const chunk of fs.createReadStream(path)) { |
| 43 | digest.update(Uint8Array.from(chunk as Buffer)); |
| 44 | } |
| 45 | return digest.digest('hex'); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Transforms map to object |
no test coverage detected