Socket
Socket
Sign inDemoInstall

currency-formatter

Package Overview
Dependencies
2
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 0.0.4

currencies.js

31

index.js

@@ -1,18 +0,19 @@

var data = require('./data');
var currencies = require('./currencies');
var accounting = require('accounting');
var find = require('lodash.find');
var CurrencyFormatter = function() {
this.defaultCurrency = {
symbol: '',
thousandsSeparator: ',',
decimalSeparator: '.',
symbolOnLeft: true,
spaceBetweenAmountAndSymbol: false,
decimalDigits: 2
}
exports.defaultCurrency = {
symbol: '',
thousandsSeparator: ',',
decimalSeparator: '.',
symbolOnLeft: true,
spaceBetweenAmountAndSymbol: false,
decimalDigits: 2
}
CurrencyFormatter.prototype.format = function (value, options) {
var currency = data.find(function(c) { return c.code === options.code; }) || this.defaultCurrency;
exports.currencies = currencies;
exports.format = function (value, options) {
var currency = find(currencies, function(c) { return c.code === options.code; }) || exports.defaultCurrency;
var symbolOnLeft = currency.symbolOnLeft;

@@ -41,6 +42,4 @@ var spaceBetweenAmountAndSymbol = currency.spaceBetweenAmountAndSymbol;

CurrencyFormatter.prototype.findCurrency = function (currencyCode) {
return data.find(function(c) { return c.code === currencyCode; });
exports.findCurrency = function (currencyCode) {
return find(currencies, function(c) { return c.code === currencyCode; });
}
module.exports = new CurrencyFormatter();
{
"name": "currency-formatter",
"version": "0.0.3",
"version": "0.0.4",
"description": "A simple Javascript utility that helps you to display currency properly",

@@ -29,4 +29,5 @@ "main": "index.js",

"dependencies": {
"accounting": "^0.4.1"
"accounting": "^0.4.1",
"lodash.find": "^4.0.0"
}
}

@@ -65,4 +65,13 @@ # Currency Formatter

You could also get a list of all the currencies here using one of the following:
```js
var currencies = require('currency-formatter/currencies');
// OR
var currencyFormatter = require('currency-formatter');
var currencies = currencyFormatter.currencies;
```
License
=
[MIT](https://github.com/smirzaei/currency-formatter/blob/master/LICENSE)

@@ -146,2 +146,12 @@ var chai = require('chai');

describe("currencies", () => {
it("should be exposed as public via require()", () => {
assert(Array.isArray(require('./currencies')));
});
it("should be exposed as public via .currencies", () => {
assert(Array.isArray(currencyFormatter.currencies));
});
})
describe("findCurrency", () => {

@@ -148,0 +158,0 @@ it("returns the expected currency for USD", () => {

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc