0.1.0 • Published 8 years ago
parse-currency v0.1.0
parse currency
Just a simple function to parse currency values.
install
npm i -S parse-currency
and use it
import parseCurrency from 'parse-currency'
// OR
const parseCurrency = require('parse-currency')
const foo = parseCurrency('$10.50')
console.log(foo) // 10.5
const bar = parseCurrency('$1,000,000.25')
console.log(bar) // 1000000.25
behavior
- it only works with USD formated currencies. for now
- if an empty string or a non-string value is passed,
parseCurrency
returnsnull
. parseCurrency
is a pure function, it does not mutate the provided string.
FAQ
- Why such small module?: Sindre gives a good answer to this.
0.1.0
8 years ago