Skip to content

Latest commit

 

History

History
64 lines (44 loc) · 2.57 KB

README.md

File metadata and controls

64 lines (44 loc) · 2.57 KB

Brown Javascript Utilities Library

Requirements

  1. Node
  2. TypeScript
  3. Yarn

To run this locally

  1. clone repo and cd into project
  2. run yarn to install dependencies

To use in a node based project

  1. add to the root of your project a .npmrc file
  2. to that new .npmrc file add the line @BrownUniversity:registry=https://npm.pkg.github.com/
  3. install the library with yarn add @BrownUniversity/[email protected] (update the version number to the latest in the repo)

To Contribute to this Library

  1. Open a PR with your addition (please one function per PR). Be sure that:
  2. New function is in TypeScript
  3. New function are added to the appropriate file or follow the structure convention of catagory_name/index.ts IE string_formmaters/index.ts
  4. Exhaustive unit tests are made for the function.
  5. 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}

  1. Test and verify the new utility and/or changes
  2. run yarn build to compile the code
  3. run yarn publish - increment the version number
  4. Good work, enjoy a nice cup of coffee.

Available Utility Functions & How to Use Them

Color Manipulation

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

Date Helper Function

Function Param(s) Result
settingsDateFormat date: string, type: "us" or "eu" or "int" sets date to specified format

Time Helper Functions

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