numbers-formatter

0.0.3 • Public • Published

Numbers Formatter

Usage Example

// Import NumbersFormatter constructor class
let NumbersFormatter = require('numbers-formatter');

// Create an instance of NumbersFormatter
// First parameter is the number or string to format
// Second parameter is JSON options object
let formatter = new NumbersFormatter(20000, {locale: 'da-DK'});

// To get the number formatted according to the locale, use `number` property
formatter.number; // 20 000,00

Supported locales

Currently supported locales:

Locale Thousands separator Radix point
Canadian (en-ca) empty space ( ) comma (,)
Danish (da-dk) empty space ( ) comma (,)
Finnish (fi-fi) empty space ( ) comma (,)
French (fr-fr) empty space ( ) comma (,)
German (de-de) empty space ( ) comma (,)
Italian (it-it) empty space (.) comma (,)
Norwegian(nb-no) empty space (.) comma (,)
Norwegian(nh-no) empty space (.) comma (,)
Spanish (es-es) empty space (.) comma (,)
Swedish (sv-se) empty space (.) comma (,)
GB-English (en-gb) empty space (,) comma (.)
US-English (en-us) empty space (,) comma (.)
Thai (th-th) empty space (,) comma (.)

To add any missing locales, make a pull request to src/locales.js with appropriate options.

TO DO:

  1. Write down the available options on README i.e. cents, custom separators and radix
  2. Add ability to use custom separators and radix
  3. Add various other checkers such as whether number is float, int, etc.
  4. Add contribution guidelines
  5. Add license

Resources

Dependencies (0)

    Dev Dependencies (9)

    Package Sidebar

    Install

    npm i numbers-formatter

    Weekly Downloads

    1

    Version

    0.0.3

    License

    ISC

    Last publish

    Collaborators

    • karolisram