Skip to content

Path.writeBytesSync() method

pathlib-ts > Path > writeBytesSync

Write raw bytes to the file.

An existing file of the same name is overwritten.

Signature:

writeBytesSync(data: Buffer | Uint8Array): void;

Parameter

Type

Description

data

Buffer | Uint8Array

Data to persist.

Returns:

void

Mirrors Path.writeBytes() but executes synchronously.

Creating a binary cache synchronously

import { Path } from "pathlib-ts";
const blob = new Path("./cache/blob.bin");
blob.writeBytesSync(Buffer.from([0xde, 0xad, 0xbe, 0xef]));