currency-formatter
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -35,4 +35,4 @@ var data = require('./data'); | ||
decimal: options.decimal || currency.decimalSeparator, | ||
thousand: options.thousand || currency.thousandsSeparator, | ||
precision: options.precision || currency.decimalDigits, | ||
thousand: options.thousand || currency.thousandsSeparator, | ||
precision: options.precision || currency.decimalDigits, | ||
format: options.format || format | ||
@@ -42,2 +42,6 @@ }) | ||
CurrencyFormatter.prototype.findCurrency = function (currencyCode) { | ||
return data.find(c => c.code === currencyCode); | ||
} | ||
module.exports = new CurrencyFormatter(); |
{ | ||
"name": "currency-formatter", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A simple Javascript utility that helps you to display currency properly", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,7 @@ # Currency Formatter | ||
Install | ||
= | ||
`npm install currency-formatter --save` | ||
Basic Usage | ||
@@ -24,2 +29,21 @@ = | ||
You can also get the currency information. | ||
```JAVASCRIPT | ||
var currencyFormatter = require('currency-formatter'); | ||
currencyFormatter.findCurrency('USD'); | ||
// returns: | ||
// { | ||
// code: 'USD', | ||
// symbol: '$', | ||
// thousandsSeparator: ',', | ||
// decimalSeparator: '.', | ||
// symbolOnLeft: true, | ||
// spaceBetweenAmountAndSymbol: false, | ||
// decimalDigits: 2 | ||
// } | ||
``` | ||
Advanced Usage | ||
@@ -26,0 +50,0 @@ = |
39
test.js
@@ -145,1 +145,40 @@ var chai = require('chai'); | ||
}) | ||
describe("findCurrency", () => { | ||
it("returns the expected currency for USD", () => { | ||
var expected = { | ||
code: 'USD', | ||
symbol: '$', | ||
thousandsSeparator: ',', | ||
decimalSeparator: '.', | ||
symbolOnLeft: true, | ||
spaceBetweenAmountAndSymbol: false, | ||
decimalDigits: 2 | ||
}; | ||
var result = currencyFormatter.findCurrency("USD"); | ||
assert.deepEqual(result, expected); | ||
}) | ||
it("returns the expected currency for EUR", () => { | ||
var expected = { | ||
code: 'EUR', | ||
symbol: '€', | ||
thousandsSeparator: ' ', | ||
decimalSeparator: ',', | ||
symbolOnLeft: false, | ||
spaceBetweenAmountAndSymbol: true, | ||
decimalDigits: 2 | ||
}; | ||
var result = currencyFormatter.findCurrency("EUR"); | ||
assert.deepEqual(result, expected); | ||
}) | ||
it("returns undefined when it can't find the currency", () => { | ||
var result = currencyFormatter.findCurrency("NON EXISTING"); | ||
assert.isUndefined(result); | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40803
1596
68