Skip to main content

Function: open()

open(path, flags, mode?): Promise<FileHandle>

Opens the file at the given path. Opening flags:

  • r: open for reading
  • w: open for writing, truncating the file if it exists
  • x: open with exclusive creation, will fail if the file exists
  • a: open for writing, appending at the end if the file exists
  • +: open for updating (reading and writing)
const f = await tjs.open('file.txt', 'r');

Parameters

path

string

The path to the file to be opened.

flags

string

Flags with which to open the file.

mode?

number

File mode bits applied if the file is created. Defaults to 0o666.

Returns

Promise<FileHandle>