Skip to content
0

katanakit-js / useFileExists

Function: useFileExists() ​

ts
function useFileExists(path): Promise<boolean>;

Defined in: src/infrastructure/filesystem/filesystem.service.ts:379

Checks whether a path exists and is accessible. Never throws: returns false for missing paths and non-Node runtimes.

Parameters ​

ParameterTypeDescription
pathstringPath to check.

Returns ​

Promise<boolean>

true when the path exists.

Example ​

ts
if (await useFileExists("data/books.json")) {
  // read it
}

Released under the MIT License.