1.2.0 • Published 1 year ago

currenzy v1.2.0

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

Currenzy - Exchange Rates

CI

Free module to get the conversion rates for dozens of currencies. Conversion rates are updated via GitHub Actions every 12 hours.

Note: The module fetches the latest rates from a URL, not the local file (i.e. there is no need to update the package to get the newest rates).

Installation

npm install currenzy

Usage

Initialize Currenzy with the base currency. If not provided, the base currency by default is EUR. Currency uses the ISO 4217 standard.

import Currenzy from 'currenzy';

const currenzy = new Currenzy('EUR');

Methods

Conversion

To make a conversion, add the amount and the target currency:

const amountInUSD = await currenzy.convert(5, 'USD');
// 5.266205

Refresh rates

The class instance downloads the latest rates from this repo, but saves the results in memory.

The convert() method automatically checks if the data is older than 6 hours. If so, it fetches again the data.

However, you can re-fetch the latest rates using the refreshRates method:

await currenzy.refreshRates();

Currencies

This is the list of supported currencies by Currenzy:

AEDBRLCZKGYDKHRMMKPGKSOSUZS
AFNBSDDJFHKDKMFMNTPHPSRDVEF
ALLBTCDKKHNLKPWMOPPKRSTDVES
AMDBTNDOPHRKKRWMROPLNSVCVND
ANGBWPDZDHTGKWDMURPYGSYPVUV
AOABYNEGPHUFKYDMVRQARSZLWST
ARSBYRERNIDRKZTMWKRONTHBXAF
AUDBZDETBILSLAKMXNRSDTJSXAG
AWGCADEURIMPLBPMYRRUBTMTXAU
AZNCDFFJDINRLKRMZNRWFTNDXCD
BAMCHFFKPIQDLRDNADSARTOPXDR
BBDCLFGBPIRRLSLNGNSBDTRYXOF
BDTCLPGELISKLTLNIOSCRTTDXPF
BGNCNYGGPJEPLVLNOKSDGTWDYER
BHDCOPGHSJMDLYDNPRSEKTZSZAR
BIFCRCGIPJODMADNZDSGDUAHZMK
BMDCUCGMDJPYMDLOMRSHPUGXZMW
BNDCUPGNFKESMGAPABSLEUSDZWL
BOBCVEGTQKGSMKDPENSLLUYU

CLI support

You can also use Currenzy from your terminal!

Install the package globally:

npm install currenzy@latest -g

Use as follows:

cur <fromAmount> <fromCurrency> <targetCurrency>

Example:

cur 1 eur usd

Would output: 1.081233 USD


Template

Used the package template from get-template

npx get-template@latest package
1.2.0

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago