Read/Write
Helper functions for reading and writing to text files.
Functions
Section titled “Functions”appendFile()
Section titled “appendFile()”function appendFile(filePath, data): Promise<void>;Defined in: functions/readWrite.ts:15
Helper function to asynchronously append data to a file. If the file does not exist, it will be automatically created.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
filePath |
string |
data |
string |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the file cannot be appended to.
deleteLineInFile()
Section titled “deleteLineInFile()”function deleteLineInFile(filePath, lineNumber): Promise<void>;Defined in: functions/readWrite.ts:35
Helper function to delete a specific line in a text file.
This assumes that the file is a text file and uses an encoding of “utf8”.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
filePath |
string |
lineNumber |
number |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the line number does not exist in the text file or the file cannot be written to.
prependFile()
Section titled “prependFile()”function prependFile(filePath, data): Promise<void>;Defined in: functions/readWrite.ts:59
Helper function to synchronously prepend data to a file.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
filePath |
string |
data |
string |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the file cannot be written to.
readFile()
Section titled “readFile()”function readFile(filePath): Promise<string>;Defined in: functions/readWrite.ts:75
Helper function to asynchronously read a file.
This assumes that the file is a text file and uses an encoding of “utf8”.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
filePath |
string |
Returns
Section titled “Returns”Promise<string>
Throws
Section titled “Throws”If the file cannot be read.
replaceLineInFile()
Section titled “replaceLineInFile()”function replaceLineInFile(filePath, lineNumber, newLine): Promise<void>;Defined in: functions/readWrite.ts:90
Helper function to replace a specific line in a text file.
This assumes that the file is a text file and uses an encoding of “utf8”.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
filePath |
string |
lineNumber |
number |
newLine |
string |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the line number does not exist in the text file or the file cannot be written to.
replaceTextInFile()
Section titled “replaceTextInFile()”function replaceTextInFile(filePath, searchValue, replaceValue): Promise<void>;Defined in: functions/readWrite.ts:117
Helper function to asynchronously replace text in a file.
This assumes that the file is a text file and uses an encoding of “utf8”.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
filePath |
string |
searchValue |
string | RegExp |
replaceValue |
string |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the file cannot be written to.
writeFile()
Section titled “writeFile()”function writeFile(filePath, data): Promise<void>;Defined in: functions/readWrite.ts:132
Helper function to asynchronously write data to a file.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
filePath |
string |
data |
string |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the file cannot be written to.
