Skip to main content

fs.promises

@listenai/lisa_core / Exports / fs / promises

Namespace: promises

fs.promises

Table of contents#

Interfaces#

Functions#

Functions#

access#

access(path, mode?): Promise<void>

Asynchronously tests a user's permissions for the file specified by path.

Parameters#

NameTypeDescription
pathPathLikeA path to a file or directory. If a URL is provided, it must use the file: protocol. URL support is experimental.
mode?number-

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:173


appendFile#

appendFile(path, data, options?): Promise<void>

Asynchronously append data to a file, creating the file if it does not exist.

Parameters#

NameTypeDescription
pathPathLike | FileHandle-
datastring | Uint8ArrayThe data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
options?BaseEncodingOptions & { flag?: OpenMode ; mode?: Mode } | BufferEncoding | nullEither the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. If encoding is not supplied, the default of 'utf8' is used. If mode is not supplied, the default of 0o666 is used. If mode is a string, it is parsed as an octal integer. If flag is not supplied, the default of 'a' is used.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:531


chmod#

chmod(path, mode): Promise<void>

Asynchronous chmod(2) - Change permissions of a file.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
modeModeA file mode. If a string is passed, it is parsed as an octal integer.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:409


chown#

chown(path, uid, gid): Promise<void>

Asynchronous chown(2) - Change ownership of a file.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
uidnumber-
gidnumber-

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:444


copyFile#

copyFile(src, dest, flags?): Promise<void>

Asynchronously copies src to dest. By default, dest is overwritten if it already exists. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.

Parameters#

NameTypeDescription
srcPathLikeA path to the source file.
destPathLikeA path to the destination file.
flags?numberAn optional integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:186


fchmod#

fchmod(handle, mode): Promise<void>

Asynchronous fchmod(2) - Change permissions of a file.

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.
modeModeA file mode. If a string is passed, it is parsed as an octal integer.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:402


fchown#

fchown(handle, uid, gid): Promise<void>

Asynchronous fchown(2) - Change ownership of a file.

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.
uidnumber-
gidnumber-

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:438


fdatasync#

fdatasync(handle): Promise<void>

Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:278


fsync#

fsync(handle): Promise<void>

Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:284


ftruncate#

ftruncate(handle, len?): Promise<void>

Asynchronous ftruncate(2) - Truncate a file to a specified length.

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.
len?numberIf not specified, defaults to 0.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:261


futimes#

futimes(handle, atime, mtime): Promise<void>

Asynchronously change file timestamps of the file referenced by the supplied FileHandle.

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.
atimestring | number | DateThe last access time. If a string is provided, it will be coerced to number.
mtimestring | number | DateThe last modified time. If a string is provided, it will be coerced to number.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:460


lchmod#

lchmod(path, mode): Promise<void>

Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
modeModeA file mode. If a string is passed, it is parsed as an octal integer.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:416


lchown#

lchown(path, uid, gid): Promise<void>

Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
uidnumber-
gidnumber-

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:422


link#

link(existingPath, newPath): Promise<void>

Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.

Parameters#

NameTypeDescription
existingPathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
newPathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:389


lstat#

lstat(path, opts?): Promise<Stats>

Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
opts?StatOptions & { bigint?: false }-

Returns#

Promise<Stats>

Defined in#

node_modules/@types/node/fs/promises.d.ts:372

lstat(path, opts): Promise<BigIntStats>

Parameters#

NameType
pathPathLike
optsStatOptions & { bigint: true }

Returns#

Promise<BigIntStats>

Defined in#

node_modules/@types/node/fs/promises.d.ts:373

lstat(path, opts?): Promise<Stats | BigIntStats>

Parameters#

NameType
pathPathLike
opts?StatOptions

Returns#

Promise<Stats | BigIntStats>

Defined in#

node_modules/@types/node/fs/promises.d.ts:374


lutimes#

lutimes(path, atime, mtime): Promise<void>

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.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
atimestring | number | DateThe last access time. If a string is provided, it will be coerced to number.
mtimestring | number | DateThe last modified time. If a string is provided, it will be coerced to number.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:432


mkdir#

mkdir(path, options): Promise<string | undefined>

Asynchronous mkdir(2) - create a directory.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
optionsMakeDirectoryOptions & { recursive: true }Either the file mode, or an object optionally specifying the file mode and whether parent folders should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to 0o777.

Returns#

Promise<string | undefined>

Defined in#

node_modules/@types/node/fs/promises.d.ts:292

mkdir(path, options?): Promise<void>

Asynchronous mkdir(2) - create a directory.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?Mode | MakeDirectoryOptions & { recursive?: false } | nullEither the file mode, or an object optionally specifying the file mode and whether parent folders should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to 0o777.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:300

mkdir(path, options?): Promise<string | undefined>

Asynchronous mkdir(2) - create a directory.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?Mode | MakeDirectoryOptions | nullEither the file mode, or an object optionally specifying the file mode and whether parent folders should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to 0o777.

Returns#

Promise<string | undefined>

Defined in#

node_modules/@types/node/fs/promises.d.ts:308


mkdtemp#

mkdtemp(prefix, options?): Promise<string>

Asynchronously creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.

Parameters#

NameTypeDescription
prefixstring-
options?BaseEncodingOptions | BufferEncoding | nullThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<string>

Defined in#

node_modules/@types/node/fs/promises.d.ts:488

mkdtemp(prefix, options): Promise<Buffer>

Asynchronously creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.

Parameters#

NameTypeDescription
prefixstring-
optionsBufferEncodingOptionThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<Buffer>

Defined in#

node_modules/@types/node/fs/promises.d.ts:495

mkdtemp(prefix, options?): Promise<string | Buffer>

Asynchronously creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.

Parameters#

NameTypeDescription
prefixstring-
options?BaseEncodingOptions | BufferEncoding | nullThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<string | Buffer>

Defined in#

node_modules/@types/node/fs/promises.d.ts:502


open#

open(path, flags, mode?): Promise<FileHandle>

Asynchronous open(2) - open and possibly create a file.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
flagsstring | number-
mode?ModeA file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to 0o666.

Returns#

Promise<FileHandle>

Defined in#

node_modules/@types/node/fs/promises.d.ts:194


opendir#

opendir(path, options?): Promise<Dir>

Parameters#

NameType
pathstring
options?OpenDirOptions

Returns#

Promise<Dir>

Defined in#

node_modules/@types/node/fs/promises.d.ts:560


read#

read<TBuffer>(handle, buffer, offset?, length?, position?): Promise<Object>

Asynchronously reads data from the file referenced by the supplied FileHandle.

Type parameters#

NameType
TBufferextends Uint8Array<TBuffer>

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.
bufferTBufferThe buffer that the data will be written to.
offset?number | nullThe offset in the buffer at which to start writing.
length?number | nullThe number of bytes to read.
position?number | nullThe offset from the beginning of the file from which data should be read. If null, data will be read from the current position.

Returns#

Promise<Object>

Defined in#

node_modules/@types/node/fs/promises.d.ts:205


readFile#

readFile(path, options?): Promise<Buffer>

Asynchronously reads the entire contents of a file.

Parameters#

NameTypeDescription
pathPathLike | FileHandleA path to a file. If a URL is provided, it must use the file: protocol. If a FileHandle is provided, the underlying file will not be closed automatically.
options?{ encoding?: null ; flag?: OpenMode } | nullAn object that may contain an optional flag. If a flag is not provided, it defaults to 'r'.

Returns#

Promise<Buffer>

Defined in#

node_modules/@types/node/fs/promises.d.ts:540

readFile(path, options): Promise<string>

Asynchronously reads the entire contents of a file.

Parameters#

NameTypeDescription
pathPathLike | FileHandleA path to a file. If a URL is provided, it must use the file: protocol. If a FileHandle is provided, the underlying file will not be closed automatically.
options{ encoding: BufferEncoding ; flag?: OpenMode } | BufferEncodingAn object that may contain an optional flag. If a flag is not provided, it defaults to 'r'.

Returns#

Promise<string>

Defined in#

node_modules/@types/node/fs/promises.d.ts:549

readFile(path, options?): Promise<string | Buffer>

Asynchronously reads the entire contents of a file.

Parameters#

NameTypeDescription
pathPathLike | FileHandleA path to a file. If a URL is provided, it must use the file: protocol. If a FileHandle is provided, the underlying file will not be closed automatically.
options?BaseEncodingOptions & { flag?: OpenMode } | BufferEncoding | nullAn object that may contain an optional flag. If a flag is not provided, it defaults to 'r'.

Returns#

Promise<string | Buffer>

Defined in#

node_modules/@types/node/fs/promises.d.ts:558


readdir#

readdir(path, options?): Promise<string[]>

Asynchronous readdir(3) - read a directory.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | nullThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<string[]>

Defined in#

node_modules/@types/node/fs/promises.d.ts:315

readdir(path, options): Promise<Buffer[]>

Asynchronous readdir(3) - read a directory.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options{ encoding: "buffer" ; withFileTypes?: false } | "buffer"The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<Buffer[]>

Defined in#

node_modules/@types/node/fs/promises.d.ts:322

readdir(path, options?): Promise<string[] | Buffer[]>

Asynchronous readdir(3) - read a directory.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | nullThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<string[] | Buffer[]>

Defined in#

node_modules/@types/node/fs/promises.d.ts:329

readdir(path, options): Promise<Dirent[]>

Asynchronous readdir(3) - read a directory.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
optionsBaseEncodingOptions & { withFileTypes: true }If called with withFileTypes: true the result data will be an array of Dirent.

Returns#

Promise<Dirent[]>

Defined in#

node_modules/@types/node/fs/promises.d.ts:336


readlink#

readlink(path, options?): Promise<string>

Asynchronous readlink(2) - read value of a symbolic link.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?BaseEncodingOptions | BufferEncoding | nullThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<string>

Defined in#

node_modules/@types/node/fs/promises.d.ts:343

readlink(path, options): Promise<Buffer>

Asynchronous readlink(2) - read value of a symbolic link.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
optionsBufferEncodingOptionThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<Buffer>

Defined in#

node_modules/@types/node/fs/promises.d.ts:350

readlink(path, options?): Promise<string | Buffer>

Asynchronous readlink(2) - read value of a symbolic link.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?BaseEncodingOptions | string | nullThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<string | Buffer>

Defined in#

node_modules/@types/node/fs/promises.d.ts:357


realpath#

realpath(path, options?): Promise<string>

Asynchronous realpath(3) - return the canonicalized absolute pathname.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?BaseEncodingOptions | BufferEncoding | nullThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<string>

Defined in#

node_modules/@types/node/fs/promises.d.ts:467

realpath(path, options): Promise<Buffer>

Asynchronous realpath(3) - return the canonicalized absolute pathname.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
optionsBufferEncodingOptionThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<Buffer>

Defined in#

node_modules/@types/node/fs/promises.d.ts:474

realpath(path, options?): Promise<string | Buffer>

Asynchronous realpath(3) - return the canonicalized absolute pathname.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?BaseEncodingOptions | BufferEncoding | nullThe encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

Returns#

Promise<string | Buffer>

Defined in#

node_modules/@types/node/fs/promises.d.ts:481


rename#

rename(oldPath, newPath): Promise<void>

Asynchronous rename(2) - Change the name or location of a file or directory.

Parameters#

NameTypeDescription
oldPathPathLikeA path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental.
newPathPathLikeA path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:247


rm#

rm(path, options?): Promise<void>

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

Parameters#

NameType
pathPathLike
options?RmOptions

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:272


rmdir#

rmdir(path, options?): Promise<void>

Asynchronous rmdir(2) - delete a directory.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
options?RmDirOptions-

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:267


stat#

stat(path, opts?): Promise<Stats>

Asynchronous stat(2) - Get file status.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
opts?StatOptions & { bigint?: false }-

Returns#

Promise<Stats>

Defined in#

node_modules/@types/node/fs/promises.d.ts:380

stat(path, opts): Promise<BigIntStats>

Parameters#

NameType
pathPathLike
optsStatOptions & { bigint: true }

Returns#

Promise<BigIntStats>

Defined in#

node_modules/@types/node/fs/promises.d.ts:381

stat(path, opts?): Promise<Stats | BigIntStats>

Parameters#

NameType
pathPathLike
opts?StatOptions

Returns#

Promise<Stats | BigIntStats>

Defined in#

node_modules/@types/node/fs/promises.d.ts:382


symlink#

symlink(target, path, type?): Promise<void>

Asynchronous symlink(2) - Create a new symbolic link to an existing file.

Parameters#

NameTypeDescription
targetPathLikeA path to an existing file. If a URL is provided, it must use the file: protocol.
pathPathLikeA path to the new symlink. If a URL is provided, it must use the file: protocol.
type?string | nullMay be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows (ignored on other platforms). When using 'junction', the target argument will automatically be normalized to an absolute path.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:366


truncate#

truncate(path, len?): Promise<void>

Asynchronous truncate(2) - Truncate a file to a specified length.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
len?numberIf not specified, defaults to 0.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:254


unlink#

unlink(path): Promise<void>

Asynchronous unlink(2) - delete a name and possibly the file it refers to.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:395


utimes#

utimes(path, atime, mtime): Promise<void>

Asynchronously change file timestamps of the file referenced by the supplied path.

Parameters#

NameTypeDescription
pathPathLikeA path to a file. If a URL is provided, it must use the file: protocol.
atimestring | number | DateThe last access time. If a string is provided, it will be coerced to number.
mtimestring | number | DateThe last modified time. If a string is provided, it will be coerced to number.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:452


write#

write<TBuffer>(handle, buffer, offset?, length?, position?): Promise<Object>

Asynchronously writes buffer to the file referenced by the supplied FileHandle. It is unsafe to call fsPromises.write() multiple times on the same file without waiting for the Promise to be resolved (or rejected). For this scenario, fs.createWriteStream is strongly recommended.

Type parameters#

NameType
TBufferextends Uint8Array<TBuffer>

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.
bufferTBufferThe buffer that the data will be written to.
offset?number | nullThe part of the buffer to be written. If not supplied, defaults to 0.
length?number | nullThe number of bytes to write. If not supplied, defaults to buffer.length - offset.
position?number | nullThe offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

Returns#

Promise<Object>

Defined in#

node_modules/@types/node/fs/promises.d.ts:223

write(handle, string, position?, encoding?): Promise<Object>

Asynchronously writes string to the file referenced by the supplied FileHandle. It is unsafe to call fsPromises.write() multiple times on the same file without waiting for the Promise to be resolved (or rejected). For this scenario, fs.createWriteStream is strongly recommended.

Parameters#

NameTypeDescription
handleFileHandleA FileHandle.
stringstringA string to write.
position?number | nullThe offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
encoding?BufferEncoding | nullThe expected string encoding.

Returns#

Promise<Object>

Defined in#

node_modules/@types/node/fs/promises.d.ts:238


writeFile#

writeFile(path, data, options?): Promise<void>

Asynchronously writes data to a file, replacing the file if it already exists. It is unsafe to call fsPromises.writeFile() multiple times on the same file without waiting for the Promise to be resolved (or rejected).

Parameters#

NameTypeDescription
pathPathLike | FileHandleA path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. If a FileHandle is provided, the underlying file will not be closed automatically.
datastring | Uint8ArrayThe data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
options?BaseEncodingOptions & { flag?: OpenMode ; mode?: Mode } | BufferEncoding | nullEither the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. If encoding is not supplied, the default of 'utf8' is used. If mode is not supplied, the default of 0o666 is used. If mode is a string, it is parsed as an octal integer. If flag is not supplied, the default of 'w' is used.

Returns#

Promise<void>

Defined in#

node_modules/@types/node/fs/promises.d.ts:517

  • 没帮助 0