I think we should use Async Iterators for this nowdays:
const getHash = async path => {
const hash = crypto.createHash('sha256');
const rs = fs.createReadStream(path);
for await (const chunk of rs) {
hash.update(chunk);
}
return hash.digest('hex');
}
I think we should use Async Iterators for this nowdays: const getHash = async path => { const hash = crypto.createHash('sha256'); const rs = fs.createReadStream(path); for await (const chunk of rs) { hash.update(chunk); } return hash.digest('hex'); }