Skip to content

unknownInterface

Interface for a path of unknown type.

WARNING

The UnknownInterface object does not guarantee that the path actually exists. It is only a helper to represent a resource and make operations easier.

Example

ts
import { 
SF
} from "@duplojs/server-utils";
const
entry
=
SF
.
createUnknownInterface
("/tmp/entry");
const
name
=
entry
.
getName
();
// name: string | null await
entry
.
exist
();
await
entry
.
stat
();
if (
SF
.
isUnknownInterface
(
entry
)) {
// entry: SF.UnknownInterface await
entry
.
stat
();
}

Syntax

typescript
function createUnknownInterface(
  path: string
): UnknownInterface
typescript
function isUnknownInterface(
  input: unknown
): input is UnknownInterface

Interface UnknownInterface

typescript
interface UnknownInterface {
  path: string;
  getName(): string | null;
  getParentPath(): string | null;
  stat(): Promise<FileSystemLeft<"stat"> | E.Success<StatInfo>>;
  exist(): Promise<FileSystemLeft<"exists"> | E.Ok>;
}

Parameters

  • path : resource path.

Return value

  • UnknownInterface : interface with getters (getName, getParentPath) and utility methods (exist, stat).

See also

Released under the MIT license.