@fragus/sam-format
v1.2.0
Published
Library for formatting different kinds of data according to type and locale
Downloads
464
Keywords
Readme
SAM-format
Formats mileage, currency, numbers, dates and phone numbers by the provider's country, currency and language. Used by SAM-api, SAM-admin-v2, SAM-superadmin-frontend and SAM-webcalc-v2.
Published to npm as @fragus/sam-format.
Using it
import { init as initFormats, formatMileage } from '@fragus/sam-format'
initFormats({ countryCode: 'DK', currencyCode: 'DKK', language: 'da-DK' })
formatMileage(150000, { symbolDisplayType: 'APPEND' }) // '150.000 km'Call init before any number or date formatter, or they throw Formatter not initialized.
Prerequisites
- Node.js: the version in
.nvmrc - yarn (
yarn.lockis the lockfile; CI uses npm)
Getting started
yarn
yarn test # jest; yarn test-watch to watch, with coverage
yarn tsc-once # build dist/, including the country and currency rulesyarn tsc builds in watch mode and leaves out the rules. Use tsc-once for a full build.
Docs
- Formatters: every function, its options and examples
- Adding a country or currency: the rules files and the build list they must be in
- Releasing: the tag that publishes to npm, and how consumers pick it up
Branches
fix/ or feature/ plus a kebab-case description. PRs target master.
