Path.writeBytes() method
pathlib-ts > Path > writeBytes
Path.writeBytes() method
Section titled “Path.writeBytes() method”Asynchronously write raw bytes to the file.
An existing file of the same name is overwritten.
Signature:
writeBytes(data: Buffer | Uint8Array): Promise<void>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
data |
Buffer | Uint8Array |
Data to persist. |
Returns:
Promise<void>
Promise that settles once the write completes.
Example
Section titled “Example”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));