Skip to content

unknownInterface ​

Interface pour un chemin de type inconnu.

WARNING

L'objet UnknownInterface ne garantit pas l'existence réelle du chemin. C'est uniquement un helper pour representer une ressource et faciliter les opérations.

Exemple ​

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
();
}

Syntaxe ​

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>;
}

Paramètres ​

  • path : chemin de la ressource.

Valeur de retour ​

  • UnknownInterface : interface avec des getters (getName, getParentPath) et des méthodes utilitaires (exist, stat).

Voir aussi ​

Diffusé sous licence MIT.