Skip to content

exists

Checks that a path exists.

Example

ts
import { 
SF
} from "@duplojs/server-utils";
import {
E
} from "@duplojs/utils";
const
result
= await
SF
.
exists
("/tmp/file.txt");
if (
E
.
isRight
(
result
)) {
// file.txt is exist }

Syntax

typescript
function exists(
  path: string | URL
): Promise<FileSystemLeft | E.Ok>

Parameters

  • path : path to check.

Return value

  • E.Ok : if the path exists.
  • FileSystemLeft : if the path does not exist or if the check fails.

See also

  • stat - Retrieves information about a path.

Released under the MIT license.