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

currency-map-symbol

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency-map-symbol - npm Package Compare versions

Comparing version 3.1.6 to 4.0.0

.travis.yml

32

currency-map-symbol.js

@@ -1,30 +0,10 @@

var currencyMapSymbol = require('./map');
var currencySymbolMap = require('./map')
var symbolCurrencyMap = {};
Object.keys(currencyMapSymbol).forEach(function (key) {
symbolCurrencyMap[currencyMapSymbol[key]] = key
})
function getSymbolFromCurrency(currencyCode) {
module.exports = function getSymbolFromCurrency (currencyCode) {
if (typeof currencyCode !== 'string') return undefined
var code = currencyCode.toUpperCase();
if (!currencyMapSymbol.hasOwnProperty(code)) return undefined
return currencyMapSymbol[code];
var code = currencyCode.toUpperCase()
if (!currencySymbolMap.hasOwnProperty(code)) return undefined
return currencySymbolMap[code]
}
function getCurrencyFromSymbol(symbol) {
if (!symbolCurrencyMap.hasOwnProperty(symbol)) return undefined
return symbolCurrencyMap[symbol]
}
function getSymbol(currencyCode) {
if (typeof currencyCode !== 'string') return '?'
var symbol = getSymbolFromCurrency(currencyCode.toUpperCase())
return symbol !== undefined ? symbol : '?'
}
module.exports = getSymbol
module.exports.getSymbolFromCurrency = getSymbolFromCurrency
module.exports.getCurrencyFromSymbol = getCurrencyFromSymbol
module.exports.symbolCurrencyMap = symbolCurrencyMap
module.exports.currencyMapSymbol = currencyMapSymbol
module.exports.currencySymbolMap = currencySymbolMap

@@ -1,168 +0,171 @@

module.exports =
{"GBP": "£"
, "USD": "$"
,"AED": "د.إ"
, "AFN": "؋"
, "ALL": "L"
, "AMD": "dram"
, "ANG": "ƒ"
, "AOA": "Kz"
, "ARS": "$"
, "AUD": "$"
, "AWG": "ƒ"
, "AZN": "₼"
, "BAM": "KM"
, "BBD": "$"
, "BDT": "৳"
, "BGN": "лв"
, "BHD": ".د.ب"
, "BIF": "FBu"
, "BMD": "$"
, "BND": "$"
, "BOB": "Bs."
, "BRL": "R$"
, "BSD": "$"
, "BTN": "Nu."
, "BWP": "P"
, "BYR": "p."
, "BZD": "BZ$"
, "CAD": "$"
, "CDF": "FC"
, "CHF": "Fr."
, "CLP": "$"
, "CNY": "¥"
, "COP": "$"
, "CRC": "₡"
, "CUC": "$"
, "CUP": "₱"
, "CVE": "$"
, "CZK": "Kč"
, "DJF": "Fdj"
, "DKK": "kr"
, "DOP": "RD$"
, "DZD": "دج"
, "EEK": "kr"
, "EGP": "£"
, "ERN": "Nfk"
, "ETB": "Br"
, "EUR": "€"
, "FJD": "$"
, "FKP": "£"
, "GEL": "₾"
, "GGP": "£"
, "GHC": "₵"
, "GHS": "GH₵"
, "GIP": "£"
, "GMD": "D"
, "GNF": "FG"
, "GTQ": "Q"
, "GYD": "$"
, "HKD": "$"
, "HNL": "L"
, "HRK": "kn"
, "HTG": "G"
, "HUF": "Ft"
, "IDR": "Rp"
, "ILS": "₪"
, "IMP": "£"
, "INR": "₹"
, "IQD": "ع.د"
, "IRR": "﷼"
, "ISK": "kr"
, "JEP": "£"
, "JMD": "J$"
, "JOD": "ينار"
, "JPY": "¥"
, "KES": "KSh"
, "KGS": "лв"
, "KHR": "៛"
, "KMF": "CF"
, "KPW": "₩"
, "KRW": "₩"
, "KWD": "K.D."
, "KYD": "$"
, "KZT": "₸"
, "LAK": "₭"
, "LBP": "£"
, "LKR": "₨"
, "LRD": "$"
, "LSL": "M"
, "LTL": "Lt"
, "LVL": "Ls"
, "LYD": "ل.د"
, "MAD": "MAD"
, "MDL": "lei"
, "MGA": "Ar"
, "MKD": "ден"
, "MMK": "K"
, "MNT": "₮"
, "MOP": "MOP$"
, "MUR": "₨"
, "MVR": "Rf"
, "MWK": "MK"
, "MXN": "$"
, "MYR": "RM"
, "MZN": "MT"
, "NAD": "$"
, "NGN": "₦"
, "NIO": "C$"
, "NOK": "kr"
, "NPR": "₨"
, "NZD": "$"
, "OMR": "﷼"
, "PAB": "B/."
, "PEN": "S/."
, "PGK": "K"
, "PHP": "₱"
, "PKR": "₨"
, "PLN": "zł"
, "PYG": "Gs"
, "QAR": "﷼"
, "RMB": "¥"
, "RON": "lei"
, "RSD": "Дин."
, "RUB": "₽"
, "RWF": "R₣"
, "SAR": "﷼"
, "SBD": "$"
, "SCR": "₨"
, "SDG": "ج.س."
, "SEK": "kr"
, "SGD": "$"
, "SHP": "£"
, "SLL": "Le"
, "SOS": "S"
, "SRD": "$"
, "SSP": "£"
, "STD": "Db"
, "SVC": "$"
, "SYP": "£"
, "SZL": "E"
, "THB": "฿"
, "TJS": "SM"
, "TMT": "T"
, "TND": "د.ت"
, "TOP": "T$"
, "TRL": "₤"
, "TRY": "₺"
, "TTD": "TT$"
, "TVD": "$"
, "TWD": "NT$"
, "TZS": "TSh"
, "UAH": "₴"
, "UGX": "USh"
, "UYU": "$U"
, "UZS": "лв"
, "VEF": "Bs"
, "VND": "₫"
, "VUV": "VT"
, "WST": "WS$"
, "XAF": "FCFA"
, "XBT": "Ƀ"
, "XCD": "$"
, "XOF": "CFA"
, "XPF": "₣"
, "YER": "﷼"
, "ZAR": "R"
, "ZWD": "Z$"
module.exports = {
'AED': 'د.إ',
'AFN': '؋',
'ALL': 'L',
'AMD': '֏',
'ANG': 'ƒ',
'AOA': 'Kz',
'ARS': '$',
'AUD': '$',
'AWG': 'ƒ',
'AZN': 'ман',
'BAM': 'KM',
'BBD': '$',
'BDT': '৳',
'BGN': 'лв',
'BHD': '.د.ب',
'BIF': 'FBu',
'BMD': '$',
'BND': '$',
'BOB': '$b',
'BRL': 'R$',
'BSD': '$',
'BTC': '฿',
'BTN': 'Nu.',
'BWP': 'P',
'BYR': 'p.',
'BZD': 'BZ$',
'CAD': '$',
'CDF': 'FC',
'CHF': 'CHF',
'CLP': '$',
'CNY': '¥',
'COP': '$',
'CRC': '₡',
'CUC': '$',
'CUP': '₱',
'CVE': '$',
'CZK': 'Kč',
'DJF': 'Fdj',
'DKK': 'kr',
'DOP': 'RD$',
'DZD': 'دج',
'EEK': 'kr',
'EGP': '£',
'ERN': 'Nfk',
'ETB': 'Br',
'ETH': 'Ξ',
'EUR': '€',
'FJD': '$',
'FKP': '£',
'GBP': '£',
'GEL': '₾',
'GGP': '£',
'GHC': '₵',
'GHS': 'GH₵',
'GIP': '£',
'GMD': 'D',
'GNF': 'FG',
'GTQ': 'Q',
'GYD': '$',
'HKD': '$',
'HNL': 'L',
'HRK': 'kn',
'HTG': 'G',
'HUF': 'Ft',
'IDR': 'Rp',
'ILS': '₪',
'IMP': '£',
'INR': '₹',
'IQD': 'ع.د',
'IRR': '﷼',
'ISK': 'kr',
'JEP': '£',
'JMD': 'J$',
'JOD': 'JD',
'JPY': '¥',
'KES': 'KSh',
'KGS': 'лв',
'KHR': '៛',
'KMF': 'CF',
'KPW': '₩',
'KRW': '₩',
'KWD': 'KD',
'KYD': '$',
'KZT': 'лв',
'LAK': '₭',
'LBP': '£',
'LKR': '₨',
'LRD': '$',
'LSL': 'M',
'LTC': 'Ł',
'LTL': 'Lt',
'LVL': 'Ls',
'LYD': 'LD',
'MAD': 'MAD',
'MDL': 'lei',
'MGA': 'Ar',
'MKD': 'ден',
'MMK': 'K',
'MNT': '₮',
'MOP': 'MOP$',
'MUR': '₨',
'MVR': 'Rf',
'MWK': 'MK',
'MXN': '$',
'MYR': 'RM',
'MZN': 'MT',
'NAD': '$',
'NGN': '₦',
'NIO': 'C$',
'NOK': 'kr',
'NPR': '₨',
'NZD': '$',
'OMR': '﷼',
'PAB': 'B/.',
'PEN': 'S/.',
'PGK': 'K',
'PHP': '₱',
'PKR': '₨',
'PLN': 'zł',
'PYG': 'Gs',
'QAR': '﷼',
'RMB': '¥',
'RON': 'lei',
'RSD': 'Дин.',
'RUB': '₽',
'RWF': 'R₣',
'SAR': '﷼',
'SBD': '$',
'SCR': '₨',
'SDG': 'ج.س.',
'SEK': 'kr',
'SGD': '$',
'SHP': '£',
'SLL': 'Le',
'SOS': 'S',
'SRD': '$',
'SSP': '£',
'STD': 'Db',
'SVC': '$',
'SYP': '£',
'SZL': 'E',
'THB': '฿',
'TJS': 'SM',
'TMT': 'T',
'TND': 'د.ت',
'TOP': 'T$',
'TRL': '₤',
'TRY': '₺',
'TTD': 'TT$',
'TVD': '$',
'TWD': 'NT$',
'TZS': 'TSh',
'UAH': '₴',
'UGX': 'USh',
'USD': '$',
'UYU': '$U',
'UZS': 'лв',
'VEF': 'Bs',
'VND': '₫',
'VUV': 'VT',
'WST': 'WS$',
'XAF': 'FCFA',
'XBT': 'Ƀ',
'XCD': '$',
'XOF': 'CFA',
'XPF': '₣',
'YER': '﷼',
'ZAR': 'R',
'ZWD': 'Z$'
}
{
"name": "currency-map-symbol",
"version": "3.1.6",
"description": "A function to lookup the currency symbol for a given currency code",
"main": "currency-map-symbol.js",
"scripts": {
"test": "./node_modules/mocha/bin/mocha test.js",
"test:watch": "./node_modules/mocha/bin/mocha test.js --watch"
},
"publishConfig": {
"registry": "http://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "git@github.com/ZakZubair/currency-map-symbol.git"
},
"keywords": [
"currency",
"symbol"
],
"author": "Zak Zubair",
"license": "MIT",
"bugs": {
"url": "https://github.com/ZakZubair/currency-map-symbol/issues"
},
"devDependencies": {
"mocha": "^2.4.5"
}
"name": "currency-map-symbol",
"version": "4.0.0",
"description": "A function to lookup the currency symbol for a given currency code",
"main": "currency-map-symbol.js",
"scripts": {
"test": "standard && tape test.js | tap-spec"
},
"keywords": [
"currency",
"currencies",
"symbols",
"symbol"
],
"author": "Zak Zubair <zakaaf@hotmail.co.uk>",
"repository": {
"type": "git",
"url": "git+https://github.com/ZakZubair/currency-map-country.git"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"license": "MIT",
"devDependencies": {
"standard": "^10.0.3",
"tap-spec": "^4.1.1",
"tape": "^4.8.0"
},
"bugs": {
"url": "https://github.com/ZakZubair/currency-map-symbol/issues"
},
"homepage": "https://github.com/ZakZubair/currency-map-symbol#readme"
}

@@ -1,8 +0,14 @@

# currency-map-symbol
<h1 align="left">
currency-map-symbol
[![Build Status](https://travis-ci.org/ZakZubair/currency-map-symbol.svg?branch=master)](https://travis-ci.org/ZakZubair/currency-map-symbol)
![](https://img.shields.io/badge/licence-MIT-blue.svg?style=flat-square)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
</h1>
A function to lookup the currency symbol for a given currency code and vice versa.
A function to lookup the currency symbol for a given currency code.
## Installation
npm i currency-map-symbol --save
npm install currency-map-symbol

@@ -13,35 +19,27 @@ ## Usage

```js
var getSymbolFromCurrency = require('currency-map-symbol').getSymbolFromCurrency;
getSymbolFromCurrency('GBP'); //=> '£'
getSymbolFromCurrency('EUR'); //=> '€'
getSymbolFromCurrency('USD'); //=> '$'
getSymbolFromCurrency('NOT A VALID CODE'); //=> undefined
```
// ES5
const getSymbolFromCurrency = require('currency-symbol-map')
### Get currency code from symbol
```js
var getCurrencyFromSymbol = require('currency-map-symbol').getCurrencyFromSymbol;
getCurrencyFromSymbol('£'); //=> 'GBP'
getCurrencyFromSymbol('€'); //=> 'EUR'
getCurrencyFromSymbol('$'); //=> 'USD'
getCurrencyFromSymbol('NOT A VALID CODE'); //=> undefined
// ES6
import getSymbolFromCurrency from 'currency-symbol-map'
getSymbolFromCurrency('GBP') //=> '£'
getSymbolFromCurrency('EUR') //=> '€'
getSymbolFromCurrency('USD') //=> '$'
getSymbolFromCurrency('NOT A VALID CODE') //=> undefined
```
### Exposed maps for other processing
### Exposed map for other processing
```js
var symbolCurrencyMap = require('currency-map-symbol').symbolCurrencyMap;
/*
{
"$": "USD",
"£": "GBP",
...
}
*/
// ES5
const getSymbolFromCurrency = require('currency-symbol-map')
var currencySymbolMap = require('currency-map-symbol').currencySymbolMap;
/*
// ES6
import getSymbolFromCurrency from 'currency-symbol-map'
/* =>
{
"USD": "$",
"GBP": "£",
...
"USD" : "$",
"GBP" : "£",
}

@@ -51,22 +49,2 @@ */

## Shorthand usage
```js
var getSymbol = require('currency-map-symbol')
getSymbol('GBP') //=> '£'
getSymbol('EUR') //=> '€'
getSymbol('USD') //=> '$'
getSymbol('NOT A VALID CODE') //=> '?'
```
## ES6 usage
```js
import {getSymbolFromCurrency} from 'currency-map-symbol';
getSymbolFromCurrency('GBP'); //=> '£'
import {getCurrencyFromSymbol} from 'currency-map-symbol';
getCurrencyFromSymbol('£'); //=> 'GBP'
```
## Tests

@@ -73,0 +51,0 @@ ```bash

@@ -1,157 +0,29 @@

var assert = require('assert');
const test = require('tape')
var getSymbol = require('./currency-map-symbol');
var getSymbolFromCurrency = require('./currency-map-symbol').getSymbolFromCurrency;
var getCurrencyFromSymbol = require('./currency-map-symbol').getCurrencyFromSymbol;
var symbolCurrencyMap = require('./currency-map-symbol').symbolCurrencyMap;
var currencySymbolMap = require('./currency-map-symbol').currencySymbolMap;
const getSymbolFromCurrency = require('./')
const currencySymbolMap = require('./map')
describe('currency-map-symbol', function() {
describe('getSymbolFromCurrency()', function () {
test('getSymbolFromCurrency(): valid params', t => {
t.equal('$', getSymbolFromCurrency('USD'), 'should return $ when USD is provided')
t.equal('£', getSymbolFromCurrency('GBP'), 'should return £ when GBP is provided')
t.equal('€', getSymbolFromCurrency('EUR'), 'should return € when EUR is provided')
t.equal('€', getSymbolFromCurrency('eur'), 'should return € when eur is provided')
t.equal(undefined, getSymbolFromCurrency('NON-EXISTENT-CODE'), 'should return undefined when code is non-existent')
t.end()
})
describe('invalid params', function() {
it('should return undefined when param is not a string', function () {
assert.equal(undefined, getSymbolFromCurrency(1));
});
test('getSymbolFromCurrency(): invalid params', t => {
t.equal(undefined, getSymbolFromCurrency(1), 'should return undefined when param is not a string')
t.equal(undefined, getSymbolFromCurrency(null), 'should return undefined when param is null')
t.equal(undefined, getSymbolFromCurrency(false), 'should return undefined when param is false')
t.equal(undefined, getSymbolFromCurrency(), 'should return undefined when param is undefined')
t.end()
})
it('should return undefined when param is null', function () {
assert.equal(undefined, getSymbolFromCurrency(null));
});
it('should return undefined when param is false', function () {
assert.equal(undefined, getSymbolFromCurrency(false));
});
it('should return undefined when param is undefined', function () {
assert.equal(undefined, getSymbolFromCurrency());
});
})
describe('valid params', function() {
it('should return $ when USD is provided', function () {
assert.equal('$', getSymbolFromCurrency('USD'));
});
it('should return £ when GBP is provided', function () {
assert.equal('£', getSymbolFromCurrency('GBP'));
});
it('should return € when EUR is provided', function () {
assert.equal('€', getSymbolFromCurrency('EUR'));
});
it('should return undefined when code is non-existent', function() {
assert.equal(undefined, getSymbolFromCurrency('NON-EXISTENT-CODE'));
});
describe('allows for lowercase params', function() {
it('should return € when EUR is provided', function () {
assert.equal('€', getSymbolFromCurrency('eur'));
});
})
})
});
describe('getCurrencyFromSymbol()', function() {
it('should return USD when $ is provided', function() {
assert.equal('USD', getCurrencyFromSymbol('$'));
});
it('should return GBP when £ is provided', function() {
assert.equal('GBP', getCurrencyFromSymbol('£'));
});
it('should return EUR when € is provided', function() {
assert.equal('EUR', getCurrencyFromSymbol('€'));
});
it('should return undefined when symbol is non-existent', function() {
assert.equal(undefined, getCurrencyFromSymbol('NON-EXISTENT-SYMBOL'));
});
});
describe('getSymbol() [deprecated]', function() {
describe('invalid params', function() {
it('should return undefined when param is not a string', function () {
assert.equal('?', getSymbol(1));
});
it('should return undefined when param is null', function () {
assert.equal('?', getSymbol(null));
});
it('should return undefined when param is false', function () {
assert.equal('?', getSymbol(false));
});
it('should return undefined when param is undefined', function () {
assert.equal('?', getSymbol());
});
})
describe('valid params', function() {
it('should return $ when USD is provided', function() {
assert.equal('$', getSymbol('USD'));
});
it('should return £ when GBP is provided', function() {
assert.equal('£', getSymbol('GBP'));
});
it('should return € when EUR is provided', function() {
assert.equal('€', getSymbol('EUR'));
});
it('should return ? when code is non-existent', function() {
assert.equal('?', getSymbol('NON-EXISTENT-CODE'));
});
describe('allows for lowercase params', function() {
it('should return € when EUR is provided', function () {
assert.equal('€', getSymbol('eur'));
});
})
})
});
});
describe('currency-map-symbol [generated]', function() {
describe('getSymbolFromCurrency()', function () {
var generateTestName = function(symbol, currency) {
return "should return " + symbol + " when " + currency + " is provided";
};
for (var symbol in symbolCurrencyMap) {
var currency = symbolCurrencyMap[symbol];
it.apply(this, [generateTestName(symbol, currency), function() {
assert.equal(symbol, getSymbolFromCurrency(currency));
}]);
}
});
describe('getCurrencyFromSymbol()', function() {
var generateTestName = function(symbol, currency) {
return "should return " + currency + " when " + symbol + " is provided";
};
for (var currency in currencySymbolMap) {
var symbol = currencySymbolMap[currency];
it.apply(this, [generateTestName(symbol, currency), function() {
assert.equal(currency, getCurrencyFromSymbol(symbol));
}]);
}
});
});
test('currency-symbol-map: sanity check every value in map', t => {
const currencies = Object.keys(currencySymbolMap)
const obj = {}
currencies.forEach(code => { obj[code] = getSymbolFromCurrency(code) })
t.deepEqual(obj, currencySymbolMap)
t.end()
})
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