Parse and format things that could be prices


Simple utility to deal with formatting and parsing price. When asking a user to input a price, you should expect just about anything:

US$ 3.900,90-
19,95 €
€ 19.99

So unless we restrict the user, we have to deal with this.

npm install format-price
    var Price = require('format-price');
    var amount = Price.parse('US$ 3.900,90-');
    // =>  -3900.90 

This is a RegExp based price parser, and it should be able to deal with most (western) number formatting, as provided by Intl.NumberFormat. See the examples in the introduction.

Format a number according to locale and currency:

    Price.format( 'fr-FR', 'EUR', 19.99 );
    // => 19,99 € 

This is really just a small wrapper around Intl.NumberFormat provided for symetry and shorter code.