1.0.1 • Published 4 years ago

@greenstreet/formatters v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

Formatters

A Library of data-type to string formatters

Build

Run npm run build to build the project. The build artifacts will be stored in the dist/ directory.

Running unit tests

Run npm run test to execute the unit tests via Jest.

Formatters

formatBoolean takes an any and returns true or false. if the input value can't be easily coerced, it returns false

formatDate takes a Date Object and optionally a format string and culture string. moment.js is used internally for formatting. Presets are

formatDateTime takes a Date Object and optionally a format string and culture string. moment.js is used internally for formatting.

formatDateAsISO takes a Date object and returns the date in ISO. e.g. 2020-09-25. An optional flag set to true will also return the time part. e.g. 2020-09-25T12:30:00

formatNumber takes a number and optionally a number of decimal places and culture string. Defaults to 0 decimal places.