Methods
# readFile(fileInputName, encoding) → {string}
Read a file synchronously with specified encoding
Parameters:
| Name | Type | Description |
|---|---|---|
fileInputName |
string
|
Path to file to read |
encoding |
string
|
File encoding (e.g., 'utf8', 'latin1') |
If file read fails
File contents as string
string
# readFileAsync(fileInputName, encoding) → {Promise.<string>}
Read a file asynchronously with specified encoding Uses fs.promises when available, falls back to callback-based API
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
fileInputName |
string
|
Path to file to read |
|
encoding |
string
|
utf8 | File encoding (default: 'utf8') |
If file read fails
Promise resolving to file contents
Promise.<string>
# writeFile(json, fileOutputName)
Write content to a file synchronously Logs confirmation message to console on success
Parameters:
| Name | Type | Description |
|---|---|---|
json |
string
|
Content to write to file |
fileOutputName |
string
|
Path to output file |
If file write fails
# writeFileAsync(json, fileOutputName) → {Promise.<void>}
Write content to a file asynchronously Uses fs.promises when available, falls back to callback-based API
Parameters:
| Name | Type | Description |
|---|---|---|
json |
string
|
Content to write to file |
fileOutputName |
string
|
Path to output file |
If file write fails
Promise that resolves when write completes
Promise.<void>