fs.promises.filehandle
@listenai/lisa_core / Exports / fs / promises / FileHandle
Interface: FileHandle
#
Table of contents#
Properties#
Methods#
Properties#
fd• Readonly
fd: number
Gets the file descriptor for this file handle.
#
Defined innode_modules/@types/node/fs/promises.d.ts:29
#
Methods#
appendFile▸ appendFile(data
, options?
): Promise
<void
>
Asynchronously append data to a file, creating the file if it does not exist. The underlying file will not be closed automatically.
The FileHandle
must have been opened for appending.
#
ParametersName | Type | Description |
---|---|---|
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? | null | BufferEncoding | BaseEncodingOptions & { flag? : OpenMode ; mode? : Mode } | 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:41
#
chmod▸ chmod(mode
): Promise
<void
>
Asynchronous fchmod(2) - Change permissions of a file.
#
ParametersName | Type | Description |
---|---|---|
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:52
#
chown▸ chown(uid
, gid
): Promise
<void
>
Asynchronous fchown(2) - Change ownership of a file.
#
ParametersName | Type |
---|---|
uid | number |
gid | number |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:46
#
close▸ close(): Promise
<void
>
Asynchronous close(2) - close a FileHandle
.
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:165
#
datasync▸ datasync(): Promise
<void
>
Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:57
#
read▸ read<TBuffer
>(buffer
, offset?
, length?
, position?
): Promise
<Object
>
Asynchronously reads data from the file.
The FileHandle
must have been opened for reading.
#
Type parametersName | Type |
---|---|
TBuffer | extends Uint8Array <TBuffer > |
#
ParametersName | Type | Description |
---|---|---|
buffer | TBuffer | The buffer that the data will be written to. |
offset? | null | number | The offset in the buffer at which to start writing. |
length? | null | number | The number of bytes to read. |
position? | null | number | 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:72
#
readFile▸ readFile(options?
): Promise
<Buffer
>
Asynchronously reads the entire contents of a file. The underlying file will not be closed automatically.
The FileHandle
must have been opened for reading.
#
ParametersName | Type | Description |
---|---|---|
options? | null | { encoding? : null ; flag? : OpenMode } | 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:80
▸ readFile(options
): Promise
<string
>
Asynchronously reads the entire contents of a file. The underlying file will not be closed automatically.
The FileHandle
must have been opened for reading.
#
ParametersName | Type | Description |
---|---|---|
options | BufferEncoding | { encoding : BufferEncoding ; flag? : OpenMode } | 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:88
▸ readFile(options?
): Promise
<string
| Buffer
>
Asynchronously reads the entire contents of a file. The underlying file will not be closed automatically.
The FileHandle
must have been opened for reading.
#
ParametersName | Type | Description |
---|---|---|
options? | null | BufferEncoding | BaseEncodingOptions & { flag? : OpenMode } | 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:96
#
readv▸ readv(buffers
, position?
): Promise
<ReadVResult
>
See fs.readv
promisified version.
#
ParametersName | Type |
---|---|
buffers | readonly ArrayBufferView [] |
position? | number |
#
ReturnsPromise
<ReadVResult
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:160
#
stat▸ stat(opts?
): Promise
<Stats
>
Asynchronous fstat(2) - Get file status.
#
ParametersName | Type |
---|---|
opts? | StatOptions & { bigint? : false } |
#
ReturnsPromise
<Stats
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:101
▸ stat(opts
): Promise
<BigIntStats
>
#
ParametersName | Type |
---|---|
opts | StatOptions & { bigint : true } |
#
ReturnsPromise
<BigIntStats
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:102
▸ stat(opts?
): Promise
<Stats
| BigIntStats
>
#
ParametersName | Type |
---|---|
opts? | StatOptions |
#
ReturnsPromise
<Stats
| BigIntStats
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:103
#
sync▸ sync(): Promise
<void
>
Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:62
#
truncate▸ truncate(len?
): Promise
<void
>
Asynchronous ftruncate(2) - Truncate a file to a specified length.
#
ParametersName | Type | Description |
---|---|---|
len? | number | If not specified, defaults to 0 . |
#
ReturnsPromise
<void
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:109
#
utimes▸ utimes(atime
, mtime
): Promise
<void
>
Asynchronously change file timestamps of the file.
#
ParametersName | Type | Description |
---|---|---|
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:116
#
write▸ write<TBuffer
>(buffer
, offset?
, length?
, position?
): Promise
<Object
>
Asynchronously writes buffer
to the file.
The FileHandle
must have been opened for writing.
#
Type parametersName | Type |
---|---|
TBuffer | extends Uint8Array <TBuffer > |
#
ParametersName | Type | Description |
---|---|---|
buffer | TBuffer | The buffer that the data will be written to. |
offset? | null | number | The part of the buffer to be written. If not supplied, defaults to 0 . |
length? | null | number | The number of bytes to write. If not supplied, defaults to buffer.length - offset . |
position? | null | number | 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:126
▸ write(data
, position?
, encoding?
): Promise
<Object
>
Asynchronously writes string
to the file.
The FileHandle
must have been opened for writing.
It is unsafe to call 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 |
---|---|---|
data | string | Uint8Array | - |
position? | null | number | The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
encoding? | null | BufferEncoding | The expected string encoding. |
#
ReturnsPromise
<Object
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:137
#
writeFile▸ writeFile(data
, options?
): Promise
<void
>
Asynchronously writes data to a file, replacing the file if it already exists. The underlying file will not be closed automatically.
The FileHandle
must have been opened for writing.
It is unsafe to call writeFile()
multiple times on the same file without waiting for the Promise
to be resolved (or rejected).
#
ParametersName | Type | Description |
---|---|---|
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? | null | BufferEncoding | BaseEncodingOptions & { flag? : OpenMode ; mode? : Mode } | 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:150
#
writev▸ writev(buffers
, position?
): Promise
<WriteVResult
>
See fs.writev
promisified version.
#
ParametersName | Type |
---|---|
buffers | readonly ArrayBufferView [] |
position? | number |
#
ReturnsPromise
<WriteVResult
>
#
Defined innode_modules/@types/node/fs/promises.d.ts:155