bun-file-io

Featured

Use for Bun file I/O: Bun.file, Bun.write, streams, directories, glob patterns, metadata.

Data & Documents 221 stars 31 forks Updated today MIT

Install

View on GitHub

Quality Score: 91/100

Stars 20%
78
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Bun File I/O Bun provides fast, optimized file operations via `Bun.file()` and `Bun.write()`. ## Reading Files ### Bun.file() ```typescript // Create file reference (lazy, doesn't read yet) const file = Bun.file("./data.txt"); // File properties console.log(file.size); // Size in bytes console.log(file.type); // MIME type console.log(file.name); // File path console.log(await file.exists()); // Boolean // Read content const text = await file.text(); const json = await file.json(); const buffer = await file.arrayBuffer(); const bytes = await file.bytes(); // Uint8Array const stream = file.stream(); // ReadableStream ``` ### Read Specific Types ```typescript // JSON file const config = await Bun.file("config.json").json(); // Text file const content = await Bun.file("readme.md").text(); // Binary file const binary = await Bun.file("image.png").arrayBuffer(); // With import attributes import data from "./data.json" with { type: "json" }; import text from "./content.txt" with { type: "text" }; ``` ## Writing Files ### Bun.write() ```typescript // Write string await Bun.write("./output.txt", "Hello World"); // Write JSON await Bun.write("./data.json", JSON.stringify({ key: "value" }, null, 2)); // Write binary await Bun.write("./output.bin", new Uint8Array([1, 2, 3])); // Write from Response const response = await fetch("https://example.com/image.png"); await Bun.write("./image.png", response); // Write from another file (efficient ...

Details

Author
secondsky
Repository
secondsky/claude-skills
Created
10 months ago
Last Updated
today
Language
TypeScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category