寫入檔案到標準輸出
Bun 通過 Bun.stdout 屬性將 stdout 暴露為一個 BunFile。將其作為目標傳遞給 Bun.write()。
以下程式碼將檔案寫入 stdout,類似於 Unix 的 cat 命令。
const path = "/path/to/file.txt";
const file = Bun.file(path);
await Bun.write(Bun.stdout, file);
請參閱 Bun.write()。
Bun 通過 Bun.stdout 屬性將 stdout 暴露為一個 BunFile。將其作為目標傳遞給 Bun.write()。
以下程式碼將檔案寫入 stdout,類似於 Unix 的 cat 命令。
const path = "/path/to/file.txt";
const file = Bun.file(path);
await Bun.write(Bun.stdout, file);
請參閱 Bun.write()。