Get Started

Import library with the following code:

npm i @marchintosh94/number-format

or

yarn add @marchintosh94/number-format

Quick Start

When you have installed the package you can configure global initial parameters

main.ts or index.ts
import { initNumberFormat } from '@marchintosh94/number-format'

// ...other code...

initNumberFormat({
  defaultDecimals: 2,
  defaultErrorValue: 0,
  delimitersChar: {
    decimal: '.',
    thousands: ','
  },
  defaultCurrecySymbol: {sign: '$', code: 'USD'}
})

Then you can format numbers in your application

import { useNumberFormat } from '@marchintosh94/number-format'


useNumberFormat(2100.3).format() => // 2,100.30
useNumberFormat(890.32).formatCurrency() => // 800.32 $

Last updated