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(buffer, offset) → {Promise.<Number>}
Reads asynchronously some bytes from the file.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
buffer |
Uint8Array
|
The buffer into which the data will be read. |
|
offset |
Number
|
0 |
The starting position in the file from which to begin reading data. |
Returns:
- Type:
-
Promise.<Number>
- The amount of bytes read.
readSync(buffer, offset) → {Number}
Reads synchronously some bytes from the file.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
buffer |
Uint8Array
|
The buffer into which the data will be read. |
|
offset |
Number
|
0 |
The starting position in the file from which to begin reading data. |
Returns:
- Type:
-
Number
- The amount of bytes read.
(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. |