Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

format-thousands

VovanR27.3kMIT2.0.0TypeScript support: definitely-typed

Format thousands with custom separator: 1 000 000

format, separate, thousands, number

readme

format-thousands

Commitizen friendly XO code style

NPM version Build Status Coveralls Status Dependency Status DevDependency Status

Format thousands with custom separator: 1 000 000

Demo: vovanr.github.io/format-thousands

Install

npm install --save format-thousands

Usage

var formatThousands = require('format-thousands');

formatThousands(1000);
//=> '1 000'

formatThousands(5000, {formatFourDigits: false});
//=> '5000'

formatThousands(1000000, '`');
//=> '1`000`000'

formatThousands(10000, {separator: "'"});
//=> "10'000"

formatThousands(-100000);
//=> "-100 000"

formatThousands(10000.0001)
//=> "10 000.0001"

formatThousands();
//=> ''

License

MIT © Vladimir Rodkin

changelog

2.0.0 (2020-12-30)

Bug Fixes

  • lib: Fix decimal and negative formatting (3cac3ef), closes #7

build

  • package: Upgrade development dependencies (495a1fd)

BREAKING CHANGES

  • package: Drop support of Node.js < v10

1.1.1 (2017-04-09)

Bug Fixes

  • lib: Fix decimal and negative formatting (4a3c779), closes #7

1.1.0 (2017-02-16)

Features

  • lib: Add formatFourDigits option (1f8c15a), closes #5

1.0.4 (2016-04-28)

Bug Fixes

  • lib: Fix bug when number 0 formatted to ''(8cf8388)

1.0.3 (2016-04-21)