Skip to content

Path.openSync() method

pathlib-ts > Path > openSync

Open the file with the given mode using the synchronous helper.

Signature:

openSync(mode?: string): fs.ReadStream;

Parameter

Type

Description

mode

string

(Optional) CPython-style mode string (for example "r", "wb").

Returns:

fs.ReadStream

A Node fs.ReadStream configured for the provided mode.

Mirrors Path.open() but executes synchronously.

Reading a template stream synchronously

import { Path } from "pathlib-ts";
const template = new Path("./templates/email.html");
const stream = template.openSync("r");
stream.pipe(process.stdout);