Socket
Socket
Sign inDemoInstall

currency-codes

Package Overview
Dependencies
2
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.2.0

55

index.js

@@ -6,32 +6,46 @@ var first = require('first-match');

var code = function(code) {
code = code.toUpperCase();
code = code.toUpperCase();
return first(data, function(c) {
return c.code === code;
});
return first(data, function(c) {
return c.code === code;
});
};
var country = function(country) {
country = country.toLowerCase();
country = country.toLowerCase();
return data.filter(function(c) {
return (c.countries || []).indexOf(country) > -1;
});
return data.filter(function(c) {
return (c.countries || []).indexOf(country) > -1;
});
};
var number = function(number) {
return first(data, function(c) {
return c.number === String(number);
});
return first(data, function(c) {
return c.number === String(number);
});
};
var codes = function() {
return data.map(function(c) {
return c.code;
});
return data.map(function(c) {
return c.code;
});
};
var numbers = function() {
var items = data.map(function(c) {
return c.number;
});
// handle cases where number is undefined (e.g. XFU and XBT)
return items.filter(function(n) {
if (n) {
return n;
}
});
};
var countries = function() {
var m = data.filter(function(c) {
return c.countries;
}).map(function(c) {
return c.countries;
});
return nub(Array.prototype.concat.apply([], m));
var m = data
.filter(function(c) {
return c.countries;
})
.map(function(c) {
return c.countries;
});
return nub(Array.prototype.concat.apply([], m));
};

@@ -43,2 +57,3 @@

exports.codes = codes;
exports.numbers = numbers;
exports.countries = countries;
{
"name": "currency-codes",
"version": "1.1.2",
"version": "1.2.0",
"description": "Lookup currency codes based on ISO 4217",

@@ -5,0 +5,0 @@ "repository": "git://github.com/freeall/currency-codes.git",

@@ -87,2 +87,19 @@ # currency-codes

## numbers()
``` js
var cc = require('currency-codes');
console.log(cc.numbers());
/*
[
'784',
'971',
...
'710',
'967'
]
*/
```
## countries()

@@ -103,4 +120,29 @@

## data
``` js
var data = require('currency-codes/data');
console.log(data);
/*
[{
code: 'AED',
number: '784',
digits: 2,
currency: 'United Arab Emirates dirham',
countries: ['united arab emirates']
}, {
code: 'AFN',
number: '971',
digits: 2,
currency: 'Afghan afghani',
countries: ['afghanistan']
}, {
...
*/
```
# License
MIT

@@ -9,2 +9,4 @@ var cc = require('./index');

assert(cc.codes().length === 179);
assert(cc.countries().length === 245);
assert(cc.countries().length === 246);
assert(cc.numbers().length === 177);
assert(cc.numbers()[0] === '784');
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc