A tool to parse numbers from different locales
npm install number-parsingWhen you are receiving data from all over the world you might encounter problems while using parseFloat or parseInt. This library is here to help you handling all locales with one single piece of code.
just run npm install number-parsing
``javascript `
var parser = require("number-parsing");
var a = parser("123'123.99USD"); // will return 123123.99
var b = parser("1234"); // will return 1234
var c = parser("123 123,777") // will return 123123.777
// and so on
or 123123. If you are dealing with strange locales which uses , as a thousand delimiter, then you might want to specify the affinity of the parser for some locale.
`javascript
var parser = require("number-parsing");
var a = parser("123,123", {
us : 0.75
fr : 0.25
} // will return 123123
var a = parser("123,123", {
fr : 0.75
us : 0.25
} // will return 123.123
`Building the tool from sources
Just run
grunt buildRun unit tests
Just run
grunt test
Contribute
Feel free to add more formats
./formats.coffee or add new tests (in the directory test/`)- Add a way to disable some formats (for example if you are sure you won't use a specific one)
- Add a way to add new formats programmatically (if are parsing a non-standard format)
- Add support for browser (and ad continuous intergration)