utils/README.md

22 lines
1.0 KiB
Markdown
Raw Permalink Normal View History

2024-01-27 17:14:47 +00:00
# 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:
2024-01-27 17:21:23 +00:00
- **convertCamelToUpperSnakeCase**(`str`: _string_)
2024-01-27 17:14:47 +00:00
- 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.
2024-01-27 17:21:23 +00:00
- _Returns_: { `__dirname`: _string_, `__filename`: _string_ }
2024-01-27 17:14:47 +00:00
- **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.