Class

FileUtils

FileUtils()

File I/O utilities for reading and writing CSV/JSON files Provides both synchronous and asynchronous file operations

Constructor

# new FileUtils()

View Source src/util/fileUtils.js, line 11

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')

View Source src/util/fileUtils.js, line 20

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')

View Source src/util/fileUtils.js, line 36

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

View Source src/util/fileUtils.js, line 63

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

View Source src/util/fileUtils.js, line 81

If file write fails

Promise that resolves when write completes

Promise.<void>