Path.writeBytesSync() method
pathlib-ts > Path > writeBytesSync
Path.writeBytesSync() method
Section titled “Path.writeBytesSync() method”Write raw bytes to the file.
An existing file of the same name is overwritten.
Signature:
writeBytesSync(data: Buffer | Uint8Array): void;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
data |
Buffer | Uint8Array |
Data to persist. |
Returns:
void
Remarks
Section titled “Remarks”Mirrors Path.writeBytes() but executes synchronously.
Example
Section titled “Example”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]));