openexchangerates / accounting.js

A lightweight JavaScript library for number, money and currency formatting - fully localisable, zero dependencies.
http://openexchangerates.github.io/accounting.js
MIT License
4.95k stars 528 forks source link

Add an option to return NaN for invalid numbers. #57

Closed aschepis closed 8 years ago

aschepis commented 11 years ago

Adds a third param to unformat() called options such that if options.returnNaN is truthy a NaN will be returned instead of zero.

philippm commented 10 years ago

Many thanks @josscrowcroft for making this library available!

Any chance you could pull in @aschepis commit? Getting some indication whether the parsed string is a valid number is highly useful. In addition the commit appears to be backwards API compatible, so existing users would be unaffected.

Thank you in advance.