money-exchange
The smallest money conversion library that actually works.
25
lines of code, 0
dependencies.
Usage
const Money = ;const fx = ; fx;
API
.init(source)
You'll need to init the library first to make it work. Init installs currency data from https://api.exchangeratesapi.io/latest.
If this API will die you can set other, there's a lot of websites providing same JSON syntax tree.
Returns promise.
.convert(amount, from, to)
Converts money. you can see all currencies with .rates
.
Returns number.
.rates
Object with currency rates.
Running without currency data provider
You can set your own currencies in .rates
object. Don't forget that base currency should equal 1
.
Example:
const Money = ;const fx = ; fxrates = "BTC": 1 "ETH": 0022 "DASH": 00111; fx;