1.0.8 • Published 2 years ago

no-comma v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

no-comma

no-comma is a javascript library for dealing with inputted numbers that include commas. Nocomma will allow you to check if the number contains commas, and remove them. You can also add commas.

Installation

npm i no-comma

Usage

const noComma = require('no-comma')

const isComma = noComma.isComma // check if input contains commas
const removeComma = noComma.removeComma // remove commas from string/number
const addComma = noComma.addComma // use commas to seperate number
const formatNumber = noComma.formatNumber // use commas to seperate number


const number = '5,000,000'
const noNumber = '5000000'


isComma(noNumber) // returns false
isComma(number) // returns true

removeComma(number) // returns 5000000
addComma(noNumber) // returns 5,000,000


formatNumber(5000000) // returns 5M (M for million)

Examples

const noComma = require('no-comma')

const isComma = noComma.isComma
const removeComma = noComma.removeComma
const addComma = noComma.addComma


// req.body.salary = 4,000,000

const salaryNoComma = removeComma(req.body.salary) // returns 4000000

//Adding the returned number with regular number
const salaryAdding = (salaryNoComma + 12) // returns 4000012

console.log(addComma(salaryAdding)) // returns 4,000,012

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago