currencies-map
TypeScript icon, indicating that this package has built-in type declarations

3.3.5 • Public • Published

Currencies Map

Currency codes mapping to currency names and symbols using native javascript API to get local currency names and symbols.

alt text

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" ...]

Package Sidebar

Install

npm i currencies-map

Weekly Downloads

782

Version

3.3.5

License

MIT

Unpacked Size

255 kB

Total Files

27

Last publish

Collaborators

  • carlsa