Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
currency-symbol-map
Advanced tools
A function to lookup the currency symbol for a given currency code
The currency-symbol-map npm package provides a simple way to get the currency symbol for a given currency code or country. It is useful for applications that need to display currency symbols dynamically based on user input or locale settings.
Get currency symbol by currency code
This feature allows you to get the currency symbol for a given currency code. For example, passing 'USD' will return the dollar symbol '$'.
const currencySymbolMap = require('currency-symbol-map');
const symbol = currencySymbolMap('USD');
console.log(symbol); // Output: $
Get currency symbol by country name
This feature allows you to get the currency symbol for a given country name. For example, passing 'United States' will return the dollar symbol '$'.
const currencySymbolMap = require('currency-symbol-map');
const symbol = currencySymbolMap('United States');
console.log(symbol); // Output: $
Get currency code by currency symbol
This feature allows you to get the currency code for a given currency symbol. For example, passing '€' will return the currency code 'EUR'.
const currencySymbolMap = require('currency-symbol-map');
const code = currencySymbolMap.symbolToCurrency('€');
console.log(code); // Output: EUR
The currency-codes package provides a comprehensive list of currency codes and their associated information, including symbols. It is more detailed and includes additional information such as currency names and numeric codes, but it requires more effort to extract just the symbol.
The currency-formatter package allows for formatting numbers as currency strings, including the appropriate currency symbol. It is more focused on formatting and includes options for locale-specific formatting, making it more versatile for applications that need to display formatted currency values.
The iso-currency package provides ISO 4217 currency codes and their associated information, including symbols. It is similar to currency-codes but focuses specifically on ISO standards, making it a good choice for applications that need to adhere to these standards.
A function to lookup the currency symbol for a given currency code.
npm install currency-symbol-map
// ES5
const getSymbolFromCurrency = require('currency-symbol-map')
// ES6
import getSymbolFromCurrency from 'currency-symbol-map'
getSymbolFromCurrency('GBP') //=> '£'
getSymbolFromCurrency('EUR') //=> '€'
getSymbolFromCurrency('USD') //=> '$'
getSymbolFromCurrency('NOT A VALID CODE') //=> undefined
// ES5
const currencyToSymbolMap = require('currency-symbol-map/map')
// ES6
import currencyToSymbolMap from 'currency-symbol-map/map'
console.log(currencyToSymbolMap)
// =>
{
"USD": "$",
"GBP": "£",
…
}
npm test
'?'
character. It now returns
undefined
so that it is up to you how to handle the failure.Currency symbols originally sourced from xe, but maintained and updated by contributors.
FAQs
A function to lookup the currency symbol for a given currency code
The npm package currency-symbol-map receives a total of 182,709 weekly downloads. As such, currency-symbol-map popularity was classified as popular.
We found that currency-symbol-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.