What is currency-symbol-map?
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.
What are currency-symbol-map's main functionalities?
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
Other packages similar to currency-symbol-map
currency-codes
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.
currency-formatter
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.
iso-currency
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.
currency-symbol-map
Nest crud-services within crud-services. Useful if you have any sort of rich
nested item within your service entities that you want to store within the same object, eg:
- delivery addresses for a customer
- downloads on an article
- available sizes of an item of clothing
Installation
npm install currency-symbol-map
Usage
var getSymbol = require('currency-symbol-map')
getSymbol('GBP')
getSymbol('EUR')
getSymbol('USD')
getSymbol('NOT A VALID CODE')
Currency symbols sourced from from ee xe.