Brown Javascript Utilities Library
- Node
- TypeScript
- Yarn
- clone repo and cd into project
- run
yarn
to install dependencies
To use in a node based project
- add to the root of your project a
.npmrc
file
- to that new
.npmrc
file add the line @BrownUniversity:registry=https://npm.pkg.github.com/
- install the library with
yarn add @BrownUniversity/[email protected]
(update the version number to the latest in the repo)
To Contribute to this Library
- Open a PR with your addition (please one function per PR). Be sure that:
- New function is in TypeScript
- New function are added to the appropriate file or follow the structure convention of
catagory_name/index.ts
IE string_formmaters/index.ts
- Exhaustive unit tests are made for the function.
-
README.md
is updated with the relevant information for the function
To Publish a new version of the package
requirements: you will need to have a GitHub PAT set to access repo
, write:packages
& delete: packages
selected (at least). Add a line to your .bashrc file
as export GITHUB_TOKEN={the new token}
- Test and verify the new utility and/or changes
- run
yarn build
to compile the code
- run
yarn publish
- increment the version number
- Good work, enjoy a nice cup of coffee.
Available Utility Functions & How to Use Them
Function |
Param(s) |
Result |
adjustColor |
string, number |
takes a color hex value and a number by how much to adjust it, up to 100 (including negative numbers) |
String Formatting Helper Functions
Function |
Param(s) |
Result |
toKebabCase |
string |
string in kebab case |
toCamelCase |
string |
string in camel case |
capitalize |
string |
capitalized string |
Function |
Param(s) |
Result |
settingsDateFormat |
date : string, type : "us" or "eu" or "int" |
sets date to specified format |
Function |
Param(s) |
Result |
formatTime |
time : string or RegExpMatchArray, militaryTime : boolean |
sets time to 24 hour format when militaryTime is true |
formatTimesWithinString |
string : string, militaryTime : boolean |
sets time from within a string to 24 hour format when militaryTime is true |