Skip to main content

fs.promises.filehandle

@listenai/lisa_core / Exports / fs / promises / FileHandle

Interface: FileHandle

fs.promises.FileHandle

Table of contents#

Properties#

Methods#

Properties#

fd#

Readonly fd: number

Gets the file descriptor for this file handle.

Defined in#

node_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.

Parameters#

NameTypeDescription
datastring | Uint8ArrayThe 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.

Returns#

Promise<void>

Defined in#

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


chmod#

chmod(mode): Promise<void>

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

Parameters#

NameTypeDescription
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:52


chown#

chown(uid, gid): Promise<void>

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

Parameters#

NameType
uidnumber
gidnumber

Returns#

Promise<void>

Defined in#

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


close#

close(): Promise<void>

Asynchronous close(2) - close a FileHandle.

Returns#

Promise<void>

Defined in#

node_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.

Returns#

Promise<void>

Defined in#

node_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 parameters#

NameType
TBufferextends Uint8Array<TBuffer>

Parameters#

NameTypeDescription
bufferTBufferThe buffer that the data will be written to.
offset?null | numberThe offset in the buffer at which to start writing.
length?null | numberThe number of bytes to read.
position?null | numberThe 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: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.

Parameters#

NameTypeDescription
options?null | { encoding?: null ; flag?: OpenMode }An 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: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.

Parameters#

NameTypeDescription
optionsBufferEncoding | { encoding: BufferEncoding ; flag?: OpenMode }An 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: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.

Parameters#

NameTypeDescription
options?null | BufferEncoding | BaseEncodingOptions & { flag?: OpenMode }An 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:96


readv#

readv(buffers, position?): Promise<ReadVResult>

See fs.readv promisified version.

Parameters#

NameType
buffersreadonly ArrayBufferView[]
position?number

Returns#

Promise<ReadVResult>

Defined in#

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


stat#

stat(opts?): Promise<Stats>

Asynchronous fstat(2) - Get file status.

Parameters#

NameType
opts?StatOptions & { bigint?: false }

Returns#

Promise<Stats>

Defined in#

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

stat(opts): Promise<BigIntStats>

Parameters#

NameType
optsStatOptions & { bigint: true }

Returns#

Promise<BigIntStats>

Defined in#

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

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

Parameters#

NameType
opts?StatOptions

Returns#

Promise<Stats | BigIntStats>

Defined in#

node_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.

Returns#

Promise<void>

Defined in#

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


truncate#

truncate(len?): Promise<void>

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

Parameters#

NameTypeDescription
len?numberIf not specified, defaults to 0.

Returns#

Promise<void>

Defined in#

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


utimes#

utimes(atime, mtime): Promise<void>

Asynchronously change file timestamps of the file.

Parameters#

NameTypeDescription
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: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 parameters#

NameType
TBufferextends Uint8Array<TBuffer>

Parameters#

NameTypeDescription
bufferTBufferThe buffer that the data will be written to.
offset?null | numberThe part of the buffer to be written. If not supplied, defaults to 0.
length?null | numberThe number of bytes to write. If not supplied, defaults to buffer.length - offset.
position?null | numberThe 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: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.

Parameters#

NameTypeDescription
datastring | Uint8Array-
position?null | numberThe offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
encoding?null | BufferEncodingThe expected string encoding.

Returns#

Promise<Object>

Defined in#

node_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).

Parameters#

NameTypeDescription
datastring | Uint8ArrayThe 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.

Returns#

Promise<void>

Defined in#

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


writev#

writev(buffers, position?): Promise<WriteVResult>

See fs.writev promisified version.

Parameters#

NameType
buffersreadonly ArrayBufferView[]
position?number

Returns#

Promise<WriteVResult>

Defined in#

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

  • 没帮助 0