Skip to content

Bun.file() 函數接受一個路徑並返回一個 BunFile 實例。使用 .exists() 方法檢查給定路徑是否存在文件。

ts
const path = "/path/to/package.json";
const file = Bun.file(path);

await file.exists(); // boolean;

請參閱 API > 文件 I/O,了解使用 BunFile 的更多信息。

Bun學習網由www.bunjs.com.cn整理維護