bungibindies/bun/bunfile

A BunFile represents a lazily-loaded file; initializing it does not actually read the file from disk.

Note from Bun — The Bun.file and Bun.write APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with Bun.file, such as mkdir or readdir, you can use Bun’s nearly complete implementation of the node:fs module.

Types

A BunFile represents a lazily-loaded file; initializing it does not actually read the file from disk.

pub type BunFile

Values

pub fn delete(file: BunFile) -> Promise(Nil)

Bunfile.delete()

  • File I/O

Unlink (delete) a file.

pub fn json(file: BunFile) -> Promise(Dynamic)

Bunfile.json()

  • File I/O

Read the contents of a file as a JSON object.

pub fn stderr() -> BunFile

Bun.stderr

  • File I/O

Write to stderr

pub fn stdin() -> BunFile

Bun.stdin

  • File I/O

Read from stdin

This is read-only

pub fn stdout() -> BunFile

Bun.stdout

  • File I/O

Write to stdout

pub fn text(file: BunFile) -> Promise(String)

Bunfile.text()

  • File I/O

Read the contents of a file as a string.

pub const unlink: fn(BunFile) -> Promise(Nil)

Bunfile.unlink()

  • File I/O

Unlink (delete) a file.

Search Document