currency-format
A small package that converts a number to currency format and visa versa.
Installation
Using cdn:
Using npm:
$ npm install --save currency-formatting
Using bower:
$ bower install currency-formatting
Example
// Returns a formatted string.// The number is formatted based on symbol, precision, decimal, thousand & format provided.currency // R 5.00currency // $ 500.56currency // € 4.999,99 // Returns a number for the string provided.currency // 500currency; // 12345678.9
API
Has two public methods:
format(number, symbol, precision, thousand, decimal, format)
unformat(value, decimal)
and a global settings object with defaults of:
var settings = symbol: "$" // default currency symbol format: "_s _v" // format of currency _s = symbol & _v = value decimal: "." // decimal point separator thousand: "," // thousand separator precision: 2 // decimal places
Tests
$ npm run test