JSPM

thousands

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10561
  • Score
    100M100P100Q137740F
  • License MIT

A micro javascript library for formatting numbers with thousands separator

Package Exports

  • thousands

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (thousands) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

thousands Build Status npm

A micro javascript library for formatting numbers with thousands separator.

Why should I use this over Number.toLocaleString()?

Number.toLocaleString() isn't supported in some browsers (< Safari 9, < IE 11), or if you're running in an older node environment (< 0.12) i18n support is not included. In most cases you will likely want to use Number.toLocaleString(), but this library allows you to format numbers no matter what your environment supports.

Install

$ npm install --save thousands

Usage

const thousands = require('thousands');

thousands(1234);      // => 1,234
thousands(123456);    // => 123,456
thousands('1234.56'); // => 1,234.56

thousands(1234, ' ');      // => 1 234
thousands(123456, ' ');    // => 123 456
thousands('1234.56', ' '); // => 1 234.56

License

MIT © Jason Wilson