Path.readBytesSync() method
pathlib-ts > Path > readBytesSync
Path.readBytesSync() method
Section titled “Path.readBytesSync() method”Read the file as raw bytes.
Signature:
readBytesSync(): Buffer;Returns:
Buffer
File contents as a Buffer.
Remarks
Section titled “Remarks”Mirrors Path.readBytes() but executes synchronously.
Example
Section titled “Example”Reading binary assets synchronously
import { Path } from "pathlib-ts";
const logo = new Path("./assets/logo.png");const buffer = logo.readBytesSync();console.log(buffer.length);