1.1.0 • Published 1 year ago

@gaignoux/currency v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Currency Localization Package

A way to get all currency information from around the world.

Installation

To install the package you can use npm or yarn:

npm install @gaignoux/currency

or

yarn add @gaignoux/currency

Usage

The package provides several useful functions for obtaining currency information. Here's an example of how to use it:

// ES5
const { getCurrencyName } = require('@gaignoux/currency');
// ES6
import {
  getCurrencySymbol,
  getCurrencyCountry,
  getCurrencyLocaleCode,
  getCurrencySymbolByLocale,
  getCurrencySymbolByCountry,
  getAllCodes,
  getAllNames,
  getAllSymbols,
  getAllLocales,
  getCurrencyObject,
} from '@gaignoux/currency';

const currencyCode = 'USD';

console.log('Name:', getCurrencyName(currencyCode));
console.log('Symbol:', getCurrencySymbol(currencyCode));
console.log('Country:', getCurrencyCountry(currencyCode));
console.log('Locale Code:', getCurrencyLocaleCode('en-US'));
console.log('Symbol by Locale:', getCurrencySymbolByLocale('en-US'));
console.log('Symbol by Country:', getCurrencySymbolByCountry('United States'));
console.log('All Codes:', getAllCodes());
console.log('All Names:', getAllNames());
console.log('All Symbols:', getAllSymbols());
console.log('All Locales:', getAllLocales());
console.log('Currency Object:', getCurrencyObject(currencyCode));

Countries covered

Locale CodeCountry
ar-AEUnited Arab Emirates
ps-AFAfghanistan
sq-ALAlbania
hy-AMArmenia
nl-AWAruba
pt-AOAngola
es-ARArgentina
en-AUAustralia
az-AZAzerbaijan
bs-BABosnia and Herzegovina
en-BBBarbados
bn-BDBangladesh
bg-BGBulgaria
ar-BHBahrain
fr-BIBurundi
en-BMBermuda
ms-BNBrunei Darussalam
es-BOBolivia
pt-BRBrazil
en-BSBahamas
dz-BTBhutan
en-BWBotswana
be-BYBelarus
en-BZBelize
en-CACanada
fr-CDDemocratic Republic of the Congo
de-CHSwitzerland
es-CLChile
zh-CNChina
es-COColombia
es-CRCosta Rica
es-CUCuba
pt-CVCabo Verde
cs-CZCzech Republic
fr-DJDjibouti
da-DKDenmark
es-DODominican Republic
ar-DZAlgeria
ar-EGEgypt
ti-EREritrea
am-ETEthiopia
en-GBUnited Kingdom
en-FJFiji
en-FKFalkland Islands (Malvinas)
ka-GEGeorgia
en-GHGhana
en-GIGibraltar
en-GMGambia
fr-GNGuinea
es-GTGuatemala
en-GYGuyana
zh-HKHong Kong
es-HNHonduras
hr-HRCroatia
ht-HTHaiti
hu-HUHungary
id-IDIndonesia
he-ILIsrael
hi-INIndia
ar-IQIraq
fa-IRIran
is-ISIceland
en-JMJamaica
ar-JOJordan
ja-JPJapan
sw-KEKenya
ky-KGKyrgyzstan
km-KHCambodia
ar-KMComoros
ko-KPDemocratic People's Republic of Korea
ko-KRRepublic of Korea
ar-KWKuwait
en-KYCayman Islands
kk-KZKazakhstan
lo-LALaos
ar-LBLebanon
si-LKSri Lanka
en-LRLiberia
st-LSLesotho
lt-LTLithuania
lv-LVLatvia
ar-LYLibya
ar-MAMorocco
ro-MDMoldova
mg-MGMadagascar
mk-MKNorth Macedonia
my-MMMyanmar
mn-MNMongolia
zh-MOMacao
ar-MRMauritania
en-MUMauritius
dv-MVMaldives
ny-MWMalawi
es-MXMexico
ms-MYMalaysia
pt-MZMozambique
af-NANamibia
ig-NGNigeria
es-NINicaragua
nb-NONorway
ne-NPNepal
en-NZNew Zealand
ar-OMOman
es-PAPanama
es-PEPeru
en-PGPapua New Guinea
en-PHPhilippines
ur-PKPakistan
pl-PLPoland
es-PYParaguay
ar-QAQatar
ro-RORomania
sr-RSSerbia
ru-RURussia
rw-RWRwanda
ar-SASaudi Arabia
en-SBSolomon Islands
en-SCSeychelles
ar-SDSudan
sv-SESweden
en-SGSingapore
en-SHSaint Helena
en-SLSierra Leone
so-SOSomalia
nl-SRSuriname
en-SSSouth Sudan
pt-STSao Tome and Principe
ar-SYSyria
ss-SZEswatini
th-THThailand
tg-TJTajikistan
tk-TMTurkmenistan
ar-TNTunisia
to-TOTonga
tr-TRTurkey
en-TTTrinidad and Tobago
zh-TWTaiwan
sw-TZTanzania
uk-UAUkraine
sw-UGUganda
en-USUnited States of America
es-UYUruguay
uz-UZUzbekistan
es-VEVenezuela
vi-VNVietnam
en-VUVanuatu
sm-WSSamoa
fr-CMCameroon
enGlobal (Generic)
en-VCSaint Vincent and the Grenadines
fr-BJBenin
fr-PFFrench Polynesia
ar-YEYemen
zu-ZASouth Africa
en-ZMZambia
nl-BEBelgium
nl-NLNetherlands
pt-PTPortugal
es-ESSpain
fr-BEBelgium (French)
fr-FRFrance
it-ITItaly
de-DEGermany
de-ATAustria
el-GRGreece
ee-EEEstonia
fi-FIFinland
ga-IEIreland
mt-MTMalta
sk-SKSlovakia
sl-SISlovenia
fr-LULuxembourg
de-LULuxembourg (German)
lb-LULuxembourg (Letzeburgesch)
cy-CYCyprus
ad-ADAndorra
al-ALAlbania
by-BYBelarus
ba-BABosnia and Herzegovina (Bosnian)
cz-CZCzech Republic
dk-DKDenmark
fo-FOFaroe Islands
gi-GIGibraltar
il-ILIsrael
xk-XKKosovo
li-LILiechtenstein
lu-LULuxembourg
md-MDMoldova
mc-MCMonaco
me-MEMontenegro
no-NONorway
rs-RSSerbia
sm-SMSan Marino
si-SISlovenia
se-SESweden
ch-CHSwitzerland
ua-UAUkraine
va-VAVatican City

Available methods

  • getCurrencySymbol(code: TCurrencyCode): string: Returns the currency symbol based on the currency code.
  • getCurrencyName(code: TCurrencyCode): string: Returns the currency name based on the currency code.
  • getCurrencyCountry(code: TCurrencyCode): string: Returns the country associated with a currency based on the currency code.
  • getCurrencyLocaleCode(locale: TCurrencyLocalCode): string: Returns the locale code associated with a currency or an array of them based on the locale code.
  • getCurrencySymbolByLocale(locale: TCurrencyLocalCode): string: Returns the currency symbol or an array of them based on the locale code.
  • getCurrencySymbolByCountry(country: string): string: Returns the currency symbol based on the country.
  • getAllCodes(): string[]: Returns all available currency codes.
  • getAllNames(): string[]: Returns all available currency names.
  • getAllSymbols(): string[]: Returns all available currency symbols.
  • getAllLocales(): string[]: Returns all available locale codes.
  • getCurrencyObject(code: TCurrencyCode): TCurrency: Returns an object containing complete information about a currency based on the currency code.

Type information

With this package, you can use the available enums and types, such as:

Types

TCurrency

The type is used to represent complete currency data, including name, symbol, locale code, and associated country.

The type consists of the following fields:

  • name: CurrencyName: The currency name.
  • symbol: CurrencySymbol: The currency symbol.
  • locale: TCurrencyLocalCode | TCurrencyLocalCode[]: The locale code associated with the currency.
  • country: CurrencyCountry: The country associated with the currency.

TCurrencyCode

Type with all available currency codes

TCurrencyLocalCode

Type with all available locale codes

TCurrencySymbol

Type with all available currency symbols

Enums

CurrencySymbol

Relationship between the currency code and its symbol.

CurrencyName

Relationship between the currency code and its name

CurrencyCode

All currency code available.

CurrencyLocale

All currency locale available.

CurrencyCountry

Relationship between the currency code and the country that uses it.

Constants

CurrencyLocaleCode

Relationship between the locale code and its currency code.

CurrencyCodeLocale

Relationship between the currency code and its locale code.

Contribute

Feel free to contribute or fork, but the purpose of this package is to be a hub of information that is often difficult to find elsewhere and is used daily in development. Clone it, make your changes, respect the organization, write a test to cover the change, and submit the PR.

1.1.0

1 year ago

1.0.0

1 year ago

0.1.10

1 year ago

0.1.2

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago