https://github.com/tpkn/chopnum
Beautify long number
https://github.com/tpkn/chopnum
Last synced: 3 months ago
JSON representation
Beautify long number
- Host: GitHub
- URL: https://github.com/tpkn/chopnum
- Owner: tpkn
- License: mit
- Created: 2019-07-03T20:04:37.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-29T17:51:16.000Z (over 5 years ago)
- Last Synced: 2025-01-14T08:12:50.789Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chopnum [](https://www.npmjs.org/package/chopnum)
Beautify long number## API
```javascript
Chopnum(num[, options])
```### num
**Type**: _Number_### options.step
**Type**: _Number_
**Default**: `3`
Chunk length### options.separator
**Type**: _String_
**Default**: ` `
Separate chunks with this symbol### options.round
**Type**: _Boolean_
**Default**: `false`
Remove fractional part## Usage
```javascript
Chopnum(12)
// => 12Chopnum(123456789)
// => '123 456 789'Chopnum(-123456789)
// => '-123 456 789'Chopnum(123456789, { step: 4 })
// => '1 2345 6789'Chopnum(123456789, { separator: '-' })
// => '123-456-789'
```## Changelog
#### v1.0.2 (2019-08-29):
- fixed bug when minus sign was perceived as part of a number