Skip to content

Path.writeBytes() method

pathlib-ts > Path > writeBytes

Asynchronously write raw bytes to the file.

An existing file of the same name is overwritten.

Signature:

writeBytes(data: Buffer | Uint8Array): Promise<void>;

Parameter

Type

Description

data

Buffer | Uint8Array

Data to persist.

Returns:

Promise<void>

Promise that settles once the write completes.

Saving streamed content asynchronously

import { Path } from "pathlib-ts";
const archive = new Path("./dist/archive.zip");
const chunks = [Buffer.from("foo"), Buffer.from("bar")];
await archive.writeBytes(Buffer.concat(chunks));