Skip to content

move

Moves a file or directory.

Example

ts
import { 
SF
} from "@duplojs/server-utils";
import {
E
} from "@duplojs/utils";
const
result
= await
SF
.
move
("/tmp/src", "/tmp/dest");
// result: E.Ok | SF.FileSystemLeft if (
E
.
isRight
(
result
)) {
// element move with success } await
SF
.
move
("/tmp/file.txt", "/tmp/archive/file.txt");

Syntax

typescript
function move(
  fromPath: string | URL,
  toPath: string | URL
): Promise<FileSystemLeft | E.Ok>

Parameters

  • fromPath : source path.
  • toPath : destination path.

Return value

  • E.Ok : if the move succeeds.
  • FileSystemLeft : if the move fails.

See also

  • copy - Copies a file or directory.

Released under the MIT license.