initNumberFormat

Initialize globally number format options

import { initNumberFormat, NumberFormatOptions } from "@marchintosh94/number-format"

const config: NumberFormatOptions = {
  defaultDecimals: 2,
  defaultErrorValue: 0,
  delimitersChar: {
    decimal: '.',
    thousands: ','
  },
  defaultCurrecySymbol: {
    code: 'USD',
    sign: '$'
  }
}

initNumberFormat(config)

NumberFormatOptions

Property
Description
Default
Required

defaultDecimals

Default number of decimals when you formatting a number without specifing number of decimals.

2

delimitersChar

Thousands and decimal number char separator.

  delimitersChar: {
    decimal: ',',
    thousands: '.'
  }

defaultErrorValue

number returned in cas of error when format functions are running

0

defaultCurrecySymbol

Default currency symbol and relative code. It is used to format number as currency

  defaultCurrecySymbol: {
    code: '',
    sign: ''
  }

Last updated