npm.io
1.0.1 • Published 6 years ago

@greenstreet/formatters

Licence
ISC
Version
1.0.1
Deps
1
Size
20 kB
Vulns
0
Weekly
0

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-25T1200

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

Keywords