Skip to content

realPath

Resolves a path to its canonical form.

Example

ts
import { 
SF
} from "@duplojs/server-utils";
import {
E
,
unwrap
} from "@duplojs/utils";
const
resolved
= await
SF
.
realPath
("/tmp/./file.txt");
// resolved: E.Success<string> | SF.FileSystemLeft if (
E
.
isRight
(
resolved
)) {
const
path
=
unwrap
(
resolved
);
// path: string }

Syntax

typescript
function realPath(
  path: string | URL
): Promise<FileSystemLeft | E.Success<string>>

Parameters

  • path : path to resolve.

Return value

  • E.Success<string> : resolved path.
  • FileSystemLeft : if resolution fails.

See also

  • stat - Retrieves information about a path.

Released under the MIT license.