Reference .exists() in File-IO Docs (#9957)

* add mention of .exists()

* show that the exists method returns a promise in the docs

* remove unnecessary white space

* update type ref to show that exists returns a promise
This commit is contained in:
David Ferguson
2024-04-11 15:24:49 -05:00
committed by GitHub
parent 57208cb02e
commit edeb75a84a

View File

@@ -43,6 +43,7 @@ A `BunFile` can point to a location on disk where a file does not exist.
const notreal = Bun.file("notreal.txt");
notreal.size; // 0
notreal.type; // "text/plain;charset=utf-8"
const exists = await notreal.exists(); // false
```
The default MIME type is `text/plain;charset=utf-8`, but it can be overridden by passing a second argument to `Bun.file`.
@@ -340,6 +341,7 @@ interface BunFile {
arrayBuffer(): Promise<ArrayBuffer>;
json(): Promise<any>;
writer(params: { highWaterMark?: number }): FileSink;
exists(): Promise<boolean>;
}
export interface FileSink {