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 0.0.1 to 0.0.2

8

index.js

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

@@ -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);
})
})
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