Usage in Deno
import * as mod from "node:fs/promises";
The fs/promises
API provides asynchronous file system methods that return
promises.
The promise APIs use the underlying Node.js threadpool to perform file system operations off the event loop thread. These operations are not synchronized or threadsafe. Care must be taken when performing multiple concurrent modifications on the same file or data corruption may occur.
Tests a user's permissions for the file or directory specified by path
.
The mode
argument is an optional integer that specifies the accessibility
checks to be performed. mode
should be either the value fs.constants.F_OK
or a mask consisting of the bitwise OR of any of fs.constants.R_OK
,fs.constants.W_OK
, and fs.constants.X_OK
(e.g.fs.constants.W_OK | fs.constants.R_OK
). Check File access constants
for
possible values of mode
.
Asynchronously append data to a file, creating the file if it does not yet
exist. data
can be a string or a Buffer
.
Changes the permissions of a file.
Changes the ownership of a file.
Asynchronously copies src
to dest
. By default, dest
is overwritten if it
already exists.
Asynchronously copies the entire directory structure from src
to dest
,
including subdirectories and files.
Changes the ownership on a symbolic link.
Changes the access and modification times of a file in the same way as fsPromises.utimes()
, with the difference that if the path refers to a
symbolic link, then the link is not dereferenced: instead, the timestamps of
the symbolic link itself are changed.
Asynchronously creates a directory.
Creates a unique temporary directory. A unique directory name is generated by
appending six random characters to the end of the provided prefix
. Due to
platform inconsistencies, avoid trailing X
characters in prefix
. Some
platforms, notably the BSDs, can return more than six random characters, and
replace trailing X
characters in prefix
with random characters.
Opens a FileHandle
.
Asynchronously open a directory for iterative scanning. See the POSIX opendir(3)
documentation for more detail.
Reads the contents of a directory.
Asynchronously reads the entire contents of a file.
Reads the contents of the symbolic link referred to by path
. See the POSIX readlink(2)
documentation for more detail. The promise is
fulfilled with thelinkString
upon success.
Determines the actual location of path
using the same semantics as thefs.realpath.native()
function.
Renames oldPath
to newPath
.
Removes files and directories (modeled on the standard POSIX rm
utility).
Removes the directory identified by path
.
Creates a symbolic link.
Truncates (shortens or extends the length) of the content at path
to len
bytes.
Change the file system timestamps of the object referenced by path
.
Returns an async iterator that watches for changes on filename
, where filename
is either a file or a directory.
Asynchronously writes data to a file, replacing the file if it already exists.data
can be a string, a buffer, an
AsyncIterable, or an
Iterable object.
Changes the permissions on a symbolic link.