1. Lazy file handle
Bun.file returns a lazy BunFile (a Blob) — no disk read happens until you ask for its contents.
Bun.file("data.json")Typorithm · easy
Step 1 of 8 · intro card
Bun APIs
Bun.file returns a lazy BunFile (a Web-standard Blob) that reads on demand with .text(), .json(), or .arrayBuffer(). Bun.write writes data to a path with optimized system calls.
Bun.file(path) returns a lazy BunFile that is also a Web-standard Blob — creating it touches no disk; the read happens only when you call .text(), .json(), or .arrayBuffer().
Because reads are asynchronous, you await the Blob method: const text = await Bun.file("data.json").text() resolves to the file's contents as a string.
Bun.write(path, data) writes strings, Blobs, or other BunFiles to disk, choosing the fastest underlying system call for the source.
Bun.file is lazy — no read until you ask.
BunFile is a Web-standard Blob with .text()/.json().
Bun.write writes data with optimized syscalls.
const text = await Bun.file("data.json").text();
await Bun.write("out.txt", "hi");Connect each part of the code to the concept before you type.
Bun.file returns a lazy BunFile (a Blob) — no disk read happens until you ask for its contents.
Bun.file("data.json")text() is the Web-standard Blob method that reads the file and resolves to a string.
.text()Reading is asynchronous, so you await the promise that text() returns.
await Bun.file("data.json").text()Bun.write writes data to a path using the fastest system call available.
await Bun.write("out.txt", "hi");Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.