@anio-fs/int--read-file-in-chunks
v5.0.1
Published
Read a file in chunks asynchronously or synchronously.
Downloads
144
Readme
@anio-fs/int--read-file-in-chunks
Read a file in chunks asynchronously or synchronously.
import {readFileInChunks} from "@anio-fs/int--read-file-in-chunks"
import {createHash} from "node:crypto"
const file = await readFileInChunks("./src/index.mjs", 18)
const hash = createHash("sha256")
while (true) {
const buffer = await file.readNextChunk()
if (!buffer) break
hash.update(buffer)
}
await file.close()
hash.setEncoding("hex")
hash.end()
console.log(hash.read())