Skip to content

Read/Write

Helper functions for reading and writing to text files.

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.

Parameter Type
filePath string
data string

Promise<void>

If the file cannot be appended to.


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

Parameter Type
filePath string
lineNumber number

Promise<void>

If the line number does not exist in the text file or the file cannot be written to.


function prependFile(filePath, data): Promise<void>;

Defined in: functions/readWrite.ts:59

Helper function to synchronously prepend data to a file.

Parameter Type
filePath string
data string

Promise<void>

If the file cannot be written to.


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

Parameter Type
filePath string

Promise<string>

If the file cannot be read.


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

Parameter Type
filePath string
lineNumber number
newLine string

Promise<void>

If the line number does not exist in the text file or the file cannot be written to.


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

Parameter Type
filePath string
searchValue string | RegExp
replaceValue string

Promise<void>

If the file cannot be written to.


function writeFile(filePath, data): Promise<void>;

Defined in: functions/readWrite.ts:132

Helper function to asynchronously write data to a file.

Parameter Type
filePath string
data string

Promise<void>

If the file cannot be written to.