Path.readBytes() method
pathlib-ts > Path > readBytes
Path.readBytes() method
Section titled “Path.readBytes() method”Read the file as raw bytes and return a promise that resolves to the binary contents of the pointed-to file as a bytes object.
Signature:
readBytes(): Promise<Buffer>;Returns:
Promise<Buffer>
Promise resolving to the binary contents.
Example
Section titled “Example”Hashing a bundle asynchronously
import { createHash } from "node:crypto";import { Path } from "pathlib-ts";
const bundle = new Path("./dist/app.js");const hash = createHash("sha256") .update(await bundle.readBytes()) .digest("hex");console.log(hash);