Constructor
new File(path, modeopt) → {File}
Creates a new File instance given a file path.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
path |
String
|
The file path for the File instance. |
|
mode |
String
|
<optional> |
The mode in which the file is to be opened. |
Returns:
- Type:
-
File
An instance of the File class.
Methods
(async) open(mode)
Asynchronously opens the file.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
mode |
string
|
r |
The mode in which the file is to be opened. |
openSync(mode)
Synchronously opens the file.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
mode |
string
|
r |
The mode in which the file is to be opened. |
(async) read(size, offset) → {Promise.<Uint8Array>}
Reads asynchronously some bytes from the file.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
size |
Number
|
The maximum amount of bytes to read. |
|
offset |
Number
|
0 |
The starting position in the file from which to begin reading data. |
Returns:
- Type:
-
Promise.<Uint8Array>
- A Uint8Array containing the bytes read from the file.
readSync(size, offset) → {Uint8Array}
Reads synchronously some bytes from the file.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
size |
Number
|
The maximum amount of bytes to read. |
|
offset |
Number
|
0 |
The starting position in the file from which to begin reading data. |
Returns:
- Type:
-
Uint8Array
- A Uint8Array containing the bytes read from the file.
(async) stat() → {Promise.<FileStats>}
Retrieves asynchronously statistics for the file.
Returns:
- Type:
-
Promise.<FileStats>
Useful information about the file.
statSync() → {FileStats}
Retrieves synchronously statistics for the file.
Returns:
- Type:
-
FileStats
Useful information about the file.
(async) write(data)
Writes asynchronously a binary buffer to the file.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array
|
The binary data to be written to the file. |