Skip to main content

@rtorcato/js-common / file

file

Functions

readFileAsString()

readFileAsString(filePath): Promise<string>

Defined in: file/index.ts:9

Reads a file as a string (UTF-8).

Parameters

filePath

string

The path to the file.

Returns

Promise<string>

The file contents as a string.


writeFileAsString()

writeFileAsString(filePath, data): Promise<void>

Defined in: file/index.ts:19

Writes a string to a file (UTF-8).

Parameters

filePath

string

The path to the file.

data

string

The string data to write.

Returns

Promise<void>


fileExists()

fileExists(filePath): Promise<boolean>

Defined in: file/index.ts:28

Checks if a file exists.

Parameters

filePath

string

The path to the file.

Returns

Promise<boolean>

True if the file exists, false otherwise.


deleteFile()

deleteFile(filePath): Promise<void>

Defined in: file/index.ts:42

Deletes a file.

Parameters

filePath

string

The path to the file.

Returns

Promise<void>


getFileExtension()

getFileExtension(filePath): string

Defined in: file/index.ts:51

Gets the file extension from a file path.

Parameters

filePath

string

The path to the file.

Returns

string

The file extension (including the dot), or an empty string if none.