currencies-map
v3.3.5
Published
Map from currency codes to currency names and symbols
Downloads
6,783
Maintainers
Readme
Currencies Map
Currency codes mapping to currency names and symbols using native javascript API to get local currency names and symbols.
It contains type declarations for Typescript.
It uses navigator.language
to show the correct currency symbol or name.
Example: Currency code USD
If your device language is es-ES
you will get:
- Currency name:
dólares estadounidenses
- Currency symbol:
US$
If your device language is en-GB
you will get:
- Currency name:
US dollars
- Currency symbol:
US$
Install
yarn add currencies-map
or
npm install currencies-map
Using it
import {Currencies} from 'currencies-map';
Getting currency name
const currencyCode = 'EUR';
console.info(currencyCode + ': ' + Currencies.names.get(currencyCode));
Output (device language es-ES)
"EUR: euros"
Getting currency symbol
const currencyCode = 'EUR';
console.info(currencyCode + ': ' + Currencies.symbols.get(currencyCode));
Output
"EUR: €"
List all names
console.info([...Currencies.names.values()]);
Output (device language es-ES)
["euros", "dólares estadounidenses", "kiats" ...]
List all symbols
console.info([...Currencies.symbols.values()]);
Output
["€", "US$", "MMK" ...]
When the currency doesn't have symbol it will show currency code.
List all currency codes
import {CODES} from 'currencies-map';
console.info(CODES);
Output
["EUR", "USD", "MMK" ...]