Skip to content

carloluis/reformat-number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reformat-Number · GitHub license

re-format javascript string-numbers with ease

GitHub license npm Codacy Badge Codacy Badge

This is a simple but opinionated number re-formatter.

  • Input: a valid number which might contain commas and a dot for decimal separation.
  • Output: same number with commas on right places (between each three digits group).

Instalation

yarn add reformat-number

Usage

const reformat = require('reformat-number');

reformat('1234567890'); // => '1,234,567,890'
reformat('123,456,7890'); // => '1,234,567,890'
reformat('-12345678.90'); // => '-12,345,678.90'
reformat('1,2,3,4,5,6'); // => '123,456'

License

MIT © Carloluis