utils/README.md

22 lines
1.0 KiB
Markdown

# ItsEricWoodward's Utils
A small collection of common libraries and functions I like to use in my Node applications.
I figure that publishing them in a [public repo](https://git.itsericwoodward.com/eric/utils) on [my gitea instance](https://git.itsericwoodward.com/eric/) will make them easier to use.
The functions exported by this library are:
- **convertCamelToUpperSnakeCase**(`str`: _string_)
- Converts textLikeThis (or TextLikeThis) to TEXT_LIKE_THIS.
- _Returns_: Converted version of `str`
- **getDirname**()
- Reads and returns variables `__dirname` and `__filename`, as with CJS Node.
- _Returns_: { `__dirname`: _string_, `__filename`: _string_ }
- **getTime**()
- _Returns_: the current time in a standardized format.
- **log**(`...msg`: _unknown[]_)
- Prints the contents of `msg` to the console with my preferred formatting.
- **readJsonIfExists**(`filePath`: _string | URL_)
- Reads the contents of the JSON or JSON5 file at indicated `filePath`.
- _Returns_: the `JSON.parse`d contents of the file.