1.0.0 • Published 1 year ago

@omnicar/sam-format v1.0.0

Weekly downloads
127
License
MIT
Repository
-
Last release
1 year ago

SAM-format

Library for formatting data according to locale and options given.

Installation (for development)

yarn or npm i (examples below are using yarn)

Installation on clients

yarn add omnicar/sam-format#0.0.1

Where #0.0.1 indicates the Github release tag.

Usage

First call initFormats.

const options = {
  countryCode: TIsoCountry,
  currencyCode: TCurrency,
  language: IsoLocale
}

initFormats(options)

Example: initFormats({ countryCode: 'DK', currencyCode: 'DKK', language: 'da-DK' })

Formatters

There are 4 formatters:

formatMileage(value, opts)

showDecimals (true | false) show decimals in formatted number

symbolDisplayType (APPEND | PREPEND | NONE) where to put symbol related to number type

formatCurrency(value, opts)

showDecimals (true | false) show decimals in formatted number

symbolDisplayType (APPEND | PREPEND | NONE) where to put symbol related to number type

formatNumber(value, showDecimals)

showDecimals (true | false) show decimals in formatted number

formatDate(value, opts)

showTime (true | false) append time in formatted date

rawFormat (string) pass date format string to format with

example: formatDate(new Date(2018-01-23), {rawFormat: 'YYYYMMDD'}) // '20189123'

Tests

To run jest tests either run:

yarn test

or to run tests in watch mode run:

yarn test-watch

Compile application (tsc):

yarn tsc

1.0.0

1 year ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.44

2 years ago

0.0.42

3 years ago

0.0.43

3 years ago

0.0.41

3 years ago

0.0.40

4 years ago

0.0.38

4 years ago

0.0.39

4 years ago

0.0.37

4 years ago

0.0.34

4 years ago

0.0.35

4 years ago

0.0.36

4 years ago

0.0.32

5 years ago

0.0.31

5 years ago

0.0.30

5 years ago

0.0.27

5 years ago

0.0.28

5 years ago

0.0.29

5 years ago

0.0.23

5 years ago

0.0.24

5 years ago

0.0.25

5 years ago

0.0.26

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago