fs.promises
@listenai/lisa_core / Exports / fs / promises
Namespace: promises
fs.promises
#
Table of contents#
Interfaces#
Functions- access
- appendFile
- chmod
- chown
- copyFile
- fchmod
- fchown
- fdatasync
- fsync
- ftruncate
- futimes
- lchmod
- lchown
- link
- lstat
- lutimes
- mkdir
- mkdtemp
- open
- opendir
- read
- readFile
- readdir
- readlink
- realpath
- rename
- rm
- rmdir
- stat
- symlink
- truncate
- unlink
- utimes
- write
- writeFile
#
Functions#
access▸ access(path
, mode?
): Promise
<void
>
Asynchronously tests a user's permissions for the file specified by path.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file or directory. If a URL is provided, it must use the file: protocol. URL support is experimental. |
mode? | number | - |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | FileHandle | - |
data | string | Uint8Array | The 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 | null | Either 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. |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:531
#
chmod▸ chmod(path
, mode
): Promise
<void
>
Asynchronous chmod(2) - Change permissions of a file.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
mode | Mode | A file mode. If a string is passed, it is parsed as an octal integer. |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:409
#
chown▸ chown(path
, uid
, gid
): Promise
<void
>
Asynchronous chown(2) - Change ownership of a file.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
uid | number | - |
gid | number | - |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
src | PathLike | A path to the source file. |
dest | PathLike | A path to the destination file. |
flags? | number | An 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. |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:186
#
fchmod▸ fchmod(handle
, mode
): Promise
<void
>
Asynchronous fchmod(2) - Change permissions of a file.
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
mode | Mode | A file mode. If a string is passed, it is parsed as an octal integer. |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:402
#
fchown▸ fchown(handle
, uid
, gid
): Promise
<void
>
Asynchronous fchown(2) - Change ownership of a file.
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
uid | number | - |
gid | number | - |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:284
#
ftruncate▸ ftruncate(handle
, len?
): Promise
<void
>
Asynchronous ftruncate(2) - Truncate a file to a specified length.
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
len? | number | If not specified, defaults to 0 . |
#
ReturnsPromise
<void
>
#
Defined innode_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
.
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
atime | string | number | Date | The last access time. If a string is provided, it will be coerced to number. |
mtime | string | number | Date | The last modified time. If a string is provided, it will be coerced to number. |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
mode | Mode | A file mode. If a string is passed, it is parsed as an octal integer. |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
uid | number | - |
gid | number | - |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
existingPath | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
newPath | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
opts? | StatOptions & { bigint? : false } | - |
#
ReturnsPromise
<Stats
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:372
▸ lstat(path
, opts
): Promise
<BigIntStats
>
#
ParametersName | Type |
---|---|
path | PathLike |
opts | StatOptions & { bigint : true } |
#
ReturnsPromise
<BigIntStats
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:373
▸ lstat(path
, opts?
): Promise
<Stats
| BigIntStats
>
#
ParametersName | Type |
---|---|
path | PathLike |
opts? | StatOptions |
#
ReturnsPromise
<Stats
| BigIntStats
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
atime | string | number | Date | The last access time. If a string is provided, it will be coerced to number. |
mtime | string | number | Date | The last modified time. If a string is provided, it will be coerced to number. |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:432
#
mkdir▸ mkdir(path
, options
): Promise
<string
| undefined
>
Asynchronous mkdir(2) - create a directory.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options | MakeDirectoryOptions & { 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 . |
#
ReturnsPromise
<string
| undefined
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:292
▸ mkdir(path
, options?
): Promise
<void
>
Asynchronous mkdir(2) - create a directory.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | Mode | MakeDirectoryOptions & { recursive? : false } | null | 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 . |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:300
▸ mkdir(path
, options?
): Promise
<string
| undefined
>
Asynchronous mkdir(2) - create a directory.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | Mode | MakeDirectoryOptions | null | 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 . |
#
ReturnsPromise
<string
| undefined
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
prefix | string | - |
options? | BaseEncodingOptions | BufferEncoding | null | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<string
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
prefix | string | - |
options | BufferEncodingOption | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<Buffer
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
prefix | string | - |
options? | BaseEncodingOptions | BufferEncoding | null | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<string
| Buffer
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:502
#
open▸ open(path
, flags
, mode?
): Promise
<FileHandle
>
Asynchronous open(2) - open and possibly create a file.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
flags | string | number | - |
mode? | Mode | A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to 0o666 . |
#
ReturnsPromise
<FileHandle
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:194
#
opendir▸ opendir(path
, options?
): Promise
<Dir
>
#
ParametersName | Type |
---|---|
path | string |
options? | OpenDirOptions |
#
ReturnsPromise
<Dir
>
#
Defined innode_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 parametersName | Type |
---|---|
TBuffer | extends Uint8Array <TBuffer > |
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
buffer | TBuffer | The buffer that the data will be written to. |
offset? | number | null | The offset in the buffer at which to start writing. |
length? | number | null | The number of bytes to read. |
position? | number | null | The offset from the beginning of the file from which data should be read. If null , data will be read from the current position. |
#
ReturnsPromise
<Object
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:205
#
readFile▸ readFile(path
, options?
): Promise
<Buffer
>
Asynchronously reads the entire contents of a file.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | FileHandle | A 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 } | null | An object that may contain an optional flag. If a flag is not provided, it defaults to 'r' . |
#
ReturnsPromise
<Buffer
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:540
▸ readFile(path
, options
): Promise
<string
>
Asynchronously reads the entire contents of a file.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | FileHandle | A 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 } | BufferEncoding | An object that may contain an optional flag. If a flag is not provided, it defaults to 'r' . |
#
ReturnsPromise
<string
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:549
▸ readFile(path
, options?
): Promise
<string
| Buffer
>
Asynchronously reads the entire contents of a file.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | FileHandle | A 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 | null | An object that may contain an optional flag. If a flag is not provided, it defaults to 'r' . |
#
ReturnsPromise
<string
| Buffer
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:558
#
readdir▸ readdir(path
, options?
): Promise
<string
[]>
Asynchronous readdir(3) - read a directory.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | BaseEncodingOptions & { withFileTypes? : false } | BufferEncoding | null | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<string
[]>
#
Defined innode_modules/@types/node/fs/promises.d.ts:315
▸ readdir(path
, options
): Promise
<Buffer
[]>
Asynchronous readdir(3) - read a directory.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A 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. |
#
ReturnsPromise
<Buffer
[]>
#
Defined innode_modules/@types/node/fs/promises.d.ts:322
▸ readdir(path
, options?
): Promise
<string
[] | Buffer
[]>
Asynchronous readdir(3) - read a directory.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | BaseEncodingOptions & { withFileTypes? : false } | BufferEncoding | null | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<string
[] | Buffer
[]>
#
Defined innode_modules/@types/node/fs/promises.d.ts:329
▸ readdir(path
, options
): Promise
<Dirent
[]>
Asynchronous readdir(3) - read a directory.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options | BaseEncodingOptions & { withFileTypes : true } | If called with withFileTypes: true the result data will be an array of Dirent. |
#
ReturnsPromise
<Dirent
[]>
#
Defined innode_modules/@types/node/fs/promises.d.ts:336
#
readlink▸ readlink(path
, options?
): Promise
<string
>
Asynchronous readlink(2) - read value of a symbolic link.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | BaseEncodingOptions | BufferEncoding | null | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<string
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:343
▸ readlink(path
, options
): Promise
<Buffer
>
Asynchronous readlink(2) - read value of a symbolic link.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options | BufferEncodingOption | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<Buffer
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:350
▸ readlink(path
, options?
): Promise
<string
| Buffer
>
Asynchronous readlink(2) - read value of a symbolic link.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | BaseEncodingOptions | string | null | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<string
| Buffer
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:357
#
realpath▸ realpath(path
, options?
): Promise
<string
>
Asynchronous realpath(3) - return the canonicalized absolute pathname.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | BaseEncodingOptions | BufferEncoding | null | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<string
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:467
▸ realpath(path
, options
): Promise
<Buffer
>
Asynchronous realpath(3) - return the canonicalized absolute pathname.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options | BufferEncodingOption | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<Buffer
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:474
▸ realpath(path
, options?
): Promise
<string
| Buffer
>
Asynchronous realpath(3) - return the canonicalized absolute pathname.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | BaseEncodingOptions | BufferEncoding | null | The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used. |
#
ReturnsPromise
<string
| Buffer
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
oldPath | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. |
newPath | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. |
#
ReturnsPromise
<void
>
#
Defined innode_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).
#
ParametersName | Type |
---|---|
path | PathLike |
options? | RmOptions |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:272
#
rmdir▸ rmdir(path
, options?
): Promise
<void
>
Asynchronous rmdir(2) - delete a directory.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
options? | RmDirOptions | - |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:267
#
stat▸ stat(path
, opts?
): Promise
<Stats
>
Asynchronous stat(2) - Get file status.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
opts? | StatOptions & { bigint? : false } | - |
#
ReturnsPromise
<Stats
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:380
▸ stat(path
, opts
): Promise
<BigIntStats
>
#
ParametersName | Type |
---|---|
path | PathLike |
opts | StatOptions & { bigint : true } |
#
ReturnsPromise
<BigIntStats
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:381
▸ stat(path
, opts?
): Promise
<Stats
| BigIntStats
>
#
ParametersName | Type |
---|---|
path | PathLike |
opts? | StatOptions |
#
ReturnsPromise
<Stats
| BigIntStats
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
target | PathLike | A path to an existing file. If a URL is provided, it must use the file: protocol. |
path | PathLike | A path to the new symlink. If a URL is provided, it must use the file: protocol. |
type? | string | null | May 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. |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:366
#
truncate▸ truncate(path
, len?
): Promise
<void
>
Asynchronous truncate(2) - Truncate a file to a specified length.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
len? | number | If not specified, defaults to 0 . |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
#
ReturnsPromise
<void
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | A path to a file. If a URL is provided, it must use the file: protocol. |
atime | string | number | Date | The last access time. If a string is provided, it will be coerced to number. |
mtime | string | number | Date | The last modified time. If a string is provided, it will be coerced to number. |
#
ReturnsPromise
<void
>
#
Defined innode_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 parametersName | Type |
---|---|
TBuffer | extends Uint8Array <TBuffer > |
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
buffer | TBuffer | The buffer that the data will be written to. |
offset? | number | null | The part of the buffer to be written. If not supplied, defaults to 0 . |
length? | number | null | The number of bytes to write. If not supplied, defaults to buffer.length - offset . |
position? | number | null | The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
#
ReturnsPromise
<Object
>
#
Defined innode_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.
#
ParametersName | Type | Description |
---|---|---|
handle | FileHandle | A FileHandle . |
string | string | A string to write. |
position? | number | null | The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
encoding? | BufferEncoding | null | The expected string encoding. |
#
ReturnsPromise
<Object
>
#
Defined innode_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).
#
ParametersName | Type | Description |
---|---|---|
path | PathLike | FileHandle | A 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. |
data | string | Uint8Array | The 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 | null | Either 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. |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:517