bungibindies/bun/bunfile

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

Note — 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

Functions

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

Write to stderr

pub fn stdin() -> BunFile

Bun.stdin Read from stdin

This is read-only

pub fn stdout() -> BunFile

Bun.stdout

Write to stdout

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

Bunfile.text()

  • File I/O

Read the contents of a file as a string.

Search Document