Skip to content

Path.readBytesSync() method

pathlib-ts > Path > readBytesSync

Read the file as raw bytes.

Signature:

readBytesSync(): Buffer;

Returns:

Buffer

File contents as a Buffer.

Mirrors Path.readBytes() but executes synchronously.

Reading binary assets synchronously

import { Path } from "pathlib-ts";
const logo = new Path("./assets/logo.png");
const buffer = logo.readBytesSync();
console.log(buffer.length);