Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

currency-formatter

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency-formatter - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

7

index.js

@@ -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 @@

24

localeFormats.json
{
"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",

@@ -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, {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc