currency-formatter
Advanced tools
Comparing version 0.0.3 to 0.0.4
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) |
10
test.js
@@ -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", () => { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
41368
1603
77
2
1
+ Addedlodash.find@^4.0.0
+ Addedlodash.find@4.6.0(transitive)