Skip to main content
namespace 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.

Functions

f
promises.access

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.

    f
    promises.appendFile

    Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a Buffer.

      f
      promises.chmod

      Changes the permissions of a file.

        f
        promises.chown

        Changes the ownership of a file.

          f
          promises.copyFile

          Asynchronously copies src to dest. By default, dest is overwritten if it already exists.

            f
            promises.cp

            Asynchronously copies the entire directory structure from src to dest, including subdirectories and files.

              f
              promises.glob

              Retrieves the files matching the specified pattern.

                f
                promises.lchown

                Changes the ownership on a symbolic link.

                  f
                  promises.lstat

                  Equivalent to fsPromises.stat() unless path refers to a symbolic link, in which case the link itself is stat-ed, not the file that it refers to. Refer to the POSIX lstat(2) document for more detail.

                    f
                    promises.lutimes

                    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.

                      f
                      promises.mkdir

                      Asynchronously creates a directory.

                        f
                        promises.mkdtemp

                        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.

                          f
                          promises.open

                          Opens a FileHandle.

                            f
                            promises.opendir

                            Asynchronously open a directory for iterative scanning. See the POSIX opendir(3) documentation for more detail.

                              f
                              promises.readdir

                              Reads the contents of a directory.

                                f
                                promises.readFile

                                Asynchronously reads the entire contents of a file.

                                  f
                                  promises.realpath

                                  Determines the actual location of path using the same semantics as the fs.realpath.native() function.

                                    f
                                    promises.rename

                                    Renames oldPath to newPath.

                                      f
                                      promises.rm

                                      Removes files and directories (modeled on the standard POSIX rm utility).

                                        f
                                        promises.rmdir

                                        Removes the directory identified by path.

                                          f
                                          promises.stat
                                          No documentation available
                                            f
                                            promises.statfs
                                            No documentation available
                                              f
                                              promises.truncate

                                              Truncates (shortens or extends the length) of the content at path to len bytes.

                                                f
                                                promises.utimes

                                                Change the file system timestamps of the object referenced by path.

                                                  f
                                                  promises.watch

                                                  Returns an async iterator that watches for changes on filename, where filenameis either a file or a directory.

                                                    f
                                                    promises.writeFile

                                                    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.

                                                      f
                                                      promises.lchmod
                                                      No documentation available

                                                        Interfaces

                                                        Variables

                                                        v
                                                        promises.constants
                                                        No documentation available
                                                          Back to top