currency-formatter
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -59,3 +59,8 @@ var accounting = require('accounting') | ||
var code = options.code || (options.locale && localeCurrency.getCurrency(options.locale)) | ||
var localeFormat = localeFormats[options.locale] || defaultLocaleFormat | ||
var localeMatch = /^([a-z]+)([_-]([a-z]+))?$/i.exec(options.locale) || [] | ||
var language = localeMatch[1] | ||
var region = localeMatch[3] | ||
var localeFormat = assign({}, defaultLocaleFormat, | ||
localeFormats[language] || {}, | ||
localeFormats[language + '-' + region] || {}) | ||
var currency = assign({}, defaultCurrency, findCurrency(code), localeFormat) | ||
@@ -62,0 +67,0 @@ |
{ | ||
"de-AT": { | ||
"de": { | ||
"thousandsSeparator": ".", | ||
@@ -9,3 +9,3 @@ "decimalSeparator": ",", | ||
}, | ||
"el-GR": { | ||
"el": { | ||
"symbolOnLeft": true, | ||
@@ -24,3 +24,3 @@ "spaceBetweenAmountAndSymbol": false, | ||
}, | ||
"es-ES": { | ||
"es": { | ||
"thousandsSeparator": ".", | ||
@@ -32,3 +32,3 @@ "decimalSeparator": ",", | ||
}, | ||
"it-IT": { | ||
"it": { | ||
"symbolOnLeft": true, | ||
@@ -40,3 +40,3 @@ "spaceBetweenAmountAndSymbol": false, | ||
}, | ||
"nl-NL": { | ||
"nl": { | ||
"symbolOnLeft": true, | ||
@@ -47,17 +47,3 @@ "spaceBetweenAmountAndSymbol": false, | ||
"decimalDigits": 2 | ||
}, | ||
"nl-BE": { | ||
"symbolOnLeft": true, | ||
"spaceBetweenAmountAndSymbol": false, | ||
"thousandsSeparator": ".", | ||
"decimalSeparator": ",", | ||
"decimalDigits": 2 | ||
}, | ||
"de-DE": { | ||
"symbolOnLeft": false, | ||
"spaceBetweenAmountAndSymbol": true, | ||
"thousandsSeparator": ".", | ||
"decimalSeparator": ",", | ||
"decimalDigits": 2 | ||
} | ||
} |
{ | ||
"name": "currency-formatter", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "A simple Javascript utility that helps you to display currency properly", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
16
test.js
@@ -161,2 +161,10 @@ var chai = require('chai') | ||
context('With locale option', () => { | ||
it('Returns 1 234,56 € for fi', () => { | ||
var result = currencyFormatter.format(1234.56, { | ||
locale: 'fi' | ||
}) | ||
assert.equal(result, '1 234,56 €') | ||
}) | ||
it('Returns €1.234,56 for nl-NL', () => { | ||
@@ -170,2 +178,10 @@ var result = currencyFormatter.format(1234.56, { | ||
it('Returns €1.234,56 for nl', () => { | ||
var result = currencyFormatter.format(1234.56, { | ||
locale: 'nl' | ||
}) | ||
assert.equal(result, '€1.234,56') | ||
}) | ||
it('Returns 1.000.000,00 € for de-DE', () => { | ||
@@ -172,0 +188,0 @@ var result = currencyFormatter.format(1000000, { |
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
1905
54236
9