1.0.2 • Published 5 years ago

chopnum v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Chopnum

Beautify long number

API

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

Chopnum(12)
// => 12

Chopnum(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