0.1.0 • Published 8 years ago

parse-currency v0.1.0

Weekly downloads
43
License
MIT
Repository
github
Last release
8 years ago

parse currency

XO code style

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 returns null.
  • parseCurrency is a pure function, it does not mutate the provided string.

FAQ