Path.openSync() method
pathlib-ts > Path > openSync
Path.openSync() method
Section titled “Path.openSync() method”Open the file with the given mode using the synchronous helper.
Signature:
openSync(mode?: string): fs.ReadStream;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
mode |
string |
(Optional) CPython-style mode string (for example |
Returns:
fs.ReadStream
A Node fs.ReadStream configured for the provided mode.
Remarks
Section titled “Remarks”Mirrors Path.open() but executes synchronously.
Example
Section titled “Example”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);