Bun 將 stdout
顯示為具有 Bun.stdout
屬性的 BunFile
。這可以用作 Bun.write()
的目的地。
此程式碼會將檔案寫入 stdout
,類似於 Unix 中的 cat
指令。
const path = "/path/to/file.txt";
const file = Bun.file(path);
await Bun.write(Bun.stdout, file);
請參閱 文件 > API > 檔案 I/O 以取得 Bun.write()
的完整文件。