Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vovanr/format-thousands
Format thousands with custom separator: 1 000 000
https://github.com/vovanr/format-thousands
utility vovanr-service
Last synced: about 1 month ago
JSON representation
Format thousands with custom separator: 1 000 000
- Host: GitHub
- URL: https://github.com/vovanr/format-thousands
- Owner: VovanR
- License: mit
- Created: 2016-01-17T12:06:15.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T18:32:22.000Z (almost 2 years ago)
- Last Synced: 2024-11-02T02:15:50.642Z (2 months ago)
- Topics: utility, vovanr-service
- Language: JavaScript
- Homepage: https://vovanr.github.io/format-thousands
- Size: 935 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# format-thousands
[![Commitizen friendly][commitizen-image]][commitizen-url]
[![XO code style][codestyle-image]][codestyle-url][![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Coveralls Status][coveralls-image]][coveralls-url]> Format thousands with custom separator: 1 000 000
Demo: [vovanr.github.io/format-thousands][demo]
## Install
```shell
npm install --save format-thousands
```## Usage
```js
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](https://github.com/VovanR)[demo]: https://vovanr.github.io/format-thousands
[commitizen-url]: https://commitizen.github.io/cz-cli/
[commitizen-image]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square[codestyle-url]: https://github.com/xojs/xo
[codestyle-image]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square[npm-url]: https://npmjs.org/package/format-thousands
[npm-image]: https://img.shields.io/npm/v/format-thousands.svg?style=flat-square[build-url]: https://github.com/VovanR/format-thousands/actions/workflows/test-workflow.yml
[build-image]: https://img.shields.io/github/actions/workflow/status/vovanr/format-thousands/test-workflow.yml?style=flat-square[coveralls-url]: https://coveralls.io/r/VovanR/format-thousands
[coveralls-image]: https://img.shields.io/coveralls/VovanR/format-thousands.svg?style=flat-square