qsu
Version:
qsu is a utility library that contains useful and frequently used functions. Start with your preferred language and the modern development environment.
1 lines • 322 B
JavaScript
import{createHash as r}from"crypto";import{createReadStream as o}from"fs";export async function getFileHashFromPath(t,e="md5"){return new Promise(((n,i)=>{if(!t)return void i(new Error("Invalid path"));const a=r(e),d=o(t);d.on("error",(r=>{i(r)})),d.on("data",(r=>{a.update(r)})),d.on("end",(()=>{n(a.digest("hex"))}))}))}