number-format-x

4.1.2 • Public • Published

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

number-format-x

Format a number.

module.exports(value, [digits], [sectionLength], [sectionDelimiter], [decimalDelimiter])string

Format a given number using fixed-point notation, with user specified digit counts and seperators. null or 'undefined' can be used for optional arguments to denote that the default value is to be used.

Kind: Exported function
Returns: string - The numerical value with the choosen formatting.

Param Type Default Description
value number The numerical value to be formatted.
[digits] number 2 The number of digits to appear after the decimal point; this may be a value between 0 and 20, inclusive.
[sectionLength] number 3 Length of integer part sections.
[sectionDelimiter] string "," Integer part section delimiter.
[decimalDelimiter] string "." Decimal delimiter.

Example

import numberFormat from 'number-format-x';
 
numberFormat(12345678.9, 3); // "12,345,678.900"
numberFormat(12345678.9, null, null, '.', ','); // "12.345.678,90"
numberFormat(123456.789, 4, 4, ' ', ':'); // "12 3456:7890"
numberFormat(12345678.9, 0, null, '-'); // "12-345-679"

Package Sidebar

Install

npm i number-format-x

Weekly Downloads

45

Version

4.1.2

License

MIT

Unpacked Size

288 kB

Total Files

11

Last publish

Collaborators

  • xotic750