number-with-commas

Convert a Number to a string with commas.

Usage no npm install needed!

<script type="module">
  import numberWithCommas from 'https://cdn.skypack.dev/number-with-commas';
</script>

README

number-with-commas

Convert a Number to a string with commas.

by Luis Eduardo Rojas Cabrera

Travis Codecov Status npm package npm downloads license

Dependency Status devDependency Status peerDependency Status

Installation

$ npm install number-with-commas --save

Quick DEMO on tonicdev

Usage

import numberWithCommas from 'number-with-commas';

t.is(numberWithCommas(10000), '10,000');
t.is(numberWithCommas(-10000), '-10,000');
t.is(numberWithCommas(1000.1001), '1,000.1,001');

API

numberWithCommas(
  x: number,
): string

Test

$ npm run lint
$ npm run test:watch

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests ($ npm test).

CHANGELOG

LICENSE

MIT: http://michaelhsu.mit-license.org