1.6.2 • Published 3 years ago

current-currency v1.6.2

Weekly downloads
147
License
MIT
Repository
github
Last release
3 years ago

current-currency 💵💶💷

Making it easy to work with currencies and cryptos!

Summary

Getting Started

Install current-currency with your favourite package manager.

  • npm install current-currency
  • yarn add current-currency

Available functions

convert

Convert is used to get the current rates of a currency.

Example

import { convert } from "current-currency";

convert("EUR", 10.2, "USD").then(res => console.log(res));
// {currency: "USD", amount: 12.35}

In the background we make use of https://exchangeratesapi.io/ to always have the current rates.

addSymbol

AddSymbol is used to add the right currency symbol in the right position using the ISO currency code.

Example

import { addSymbol } from "current-currency";

const symbolized = addSymbol("RUB", 10.2);
console.log(symbolized);
// ₽10.2

Example with force position

import { addSymbol } from "current-currency";

const symbolized = addSymbol("USD", 10.2, "post");
console.log(symbolized);
// 10.2$

extract

Extract is used to retrieve information about a currency using the ISO currency code.

Example

import { extract } from "current-currency";

const extraction = extract("10.2RUB");
console.log(extraction);
// { type: "currency", name: "Russian ruble", symbol: "₽", decimal: ",", position: "pre" }

Supported currencies

CodeName
EUREuro
USDUnited States Dollar
CADCanadian Dollar
HKDHong Kong Dollar
ISKIcelandic Króna
PHPPhilippine Peso
DDKDanish Krone
HUFHungarian Forint
CZKCzech Koruna
AUDAustralian Dollar
RONRomanian Leu
SEKSwedish Krona
IDRIndonesian Rupiah
INRIndian Rupee
BRLBrazilian Real
RUBRussian Ruble
HRKCroatian Kuna
JPYJapanse Yen
TBHThai Baht
CHFSwiss Franc
SGDSingapore Dollar
PLNPolish złoty
BGNBulgarian Lev
TRYTurkish Lira
CNYChinese Renminbi
NOKNorwegian Krone
NZDNew Zealand Dollar
ZARSouth African Rand
MXNMexican Peso
ILSIsraeli Shekel
GBPPound Sterling
KRWSouth Korean Won
MYRMalaysian Ringgit

Supported cryptocurrencies

CodeName
BTCBitcoin
ETHEthereum
LTCLitecoin
XRPRipple
DOGEDogecoin
1.6.2

3 years ago

1.6.0

3 years ago

1.4.4

3 years ago

1.5.0

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago