Utils
Helper functions that do not belong to any category in particular.
Functions
diff()
function diff(string1, string2): void;
Defined in: functions/utils.ts:13
Helper function to print the differences between two strings. Similar to the diff Unix program.
Parameters
| Parameter | Type |
|---|---|
string1 | string |
string2 | string |
Returns
void
fatalError()
function fatalError(...args): never;
Defined in: functions/utils.ts:29
Helper function to print out an error message and then exit the program.
All of the arguments will be passed to the console.error function.
Parameters
| Parameter | Type |
|---|---|
...args | readonly unknown[] |
Returns
never
getArgs()
function getArgs(): readonly string[];
Defined in: functions/utils.ts:39
Helper function to get the command-line arguments passed to the program/script.
This is an alias for: process.argv.slice(2)
Returns
readonly string[]
isMain()
function isMain(importMetaFilename): boolean;
Defined in: functions/utils.ts:54
Helper function to see if the current file is is the JavaScript/TypeScript entry point. Returns false if the current file was imported from somewhere else.
This is similar to the __name__ == "__main__" pattern from the Python programming language.
Under the hood, this checks to see if the file path of the calling function is equal to
process.argv[1].
Parameters
| Parameter | Type | Description |
|---|---|---|
importMetaFilename | string | The value of import.meta.filename. |
Returns
boolean