### Hierarchy

- FileHandle

## Index

### Properties

- fd

### Methods

- appendFile
- chmod
- chown
- close
- datasync
- read
- readFile
- stat
- sync
- truncate
- utimes
- write
- writeFile

## Properties

### fd

fd: number

- Defined in node_modules/@types/node/fs.d.ts:1789

Gets the file descriptor for this file handle.

## Methods

### appendFile

- appendFile(data: any, options?: object | string | null): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1801

  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

  - ##### data: any

    The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.

  - ##### Optional options: object | string | 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.

  #### Returns Promise<void>

### chmod

- chmod(mode: string | number): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1812

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

  #### Parameters

  - ##### mode: string | number

    A file mode. If a string is passed, it is parsed as an octal integer.

  #### Returns Promise<void>

### chown

- chown(uid: number, gid: number): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1806

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

  #### Parameters

  - ##### uid: number

  - ##### gid: number

  #### Returns Promise<void>

### close

- close(): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1913

  Asynchronous close(2) - close a `FileHandle`.

  #### Returns Promise<void>

### datasync

- datasync(): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1817

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

  #### Returns Promise<void>

### read

- read<TBuffer>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<object>

- - Defined in node_modules/@types/node/fs.d.ts:1832

  Asynchronously reads data from the file. The `FileHandle` must have been opened for reading.

  #### Type parameters

  - #### TBuffer: Buffer | Uint8Array

  #### Parameters

  - ##### buffer: TBuffer

    The buffer that the data will be written to.

  - ##### Optional offset: number | null

    The offset in the buffer at which to start writing.

  - ##### Optional length: number | null

    The number of bytes to read.

  - ##### Optional 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.

  #### Returns Promise<object>

### readFile

- readFile(options?: object | null): Promise<Buffer>
- readFile(options: object | BufferEncoding): Promise<string>
- readFile(options?: object | string | null): Promise<string | Buffer>

- - Defined in node_modules/@types/node/fs.d.ts:1840

  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

  - ##### Optional options: object | null

    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.d.ts:1848

  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

  - ##### options: object | BufferEncoding

    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.d.ts:1856

  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

  - ##### Optional options: object | string | null

    An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.

  #### Returns Promise<string | Buffer>

### stat

- stat(): Promise<Stats>

- - Defined in node_modules/@types/node/fs.d.ts:1861

  Asynchronous fstat(2) - Get file status.

  #### Returns Promise<Stats>

### sync

- sync(): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1822

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

  #### Returns Promise<void>

### truncate

- truncate(len?: undefined | number): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1867

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

  #### Parameters

  - ##### Optional len: undefined | number

    If not specified, defaults to `0`.

  #### Returns Promise<void>

### utimes

- utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1874

  Asynchronously change file timestamps of the file.

  #### Parameters

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

  #### Returns Promise<void>

### write

- write<TBuffer>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<object>
- write(data: any, position?: number | null, encoding?: string | null): Promise<object>

- - Defined in node_modules/@types/node/fs.d.ts:1884

  Asynchronously writes `buffer` to the file. The `FileHandle` must have been opened for writing.

  #### Type parameters

  - #### TBuffer: Buffer | Uint8Array

  #### Parameters

  - ##### buffer: TBuffer

    The buffer that the data will be written to.

  - ##### Optional offset: number | null

    The part of the buffer to be written. If not supplied, defaults to `0`.

  - ##### Optional length: number | null

    The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.

  - ##### Optional 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.

  #### Returns Promise<object>

- - Defined in node_modules/@types/node/fs.d.ts:1895

  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

  - ##### data: any

  - ##### Optional 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.

  - ##### Optional encoding: string | null

    The expected string encoding.

  #### Returns Promise<object>

### writeFile

- writeFile(data: any, options?: object | string | null): Promise<void>

- - Defined in node_modules/@types/node/fs.d.ts:1908

  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

  - ##### data: any

    The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.

  - ##### Optional options: object | string | 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.

  #### Returns Promise<void>

Generated using TypeDoc