openexchangerates / money.js

money.js is a tiny (1kb) javascript currency conversion library, for web & nodeJS
http://openexchangerates.github.io/money.js
MIT License
1.46k stars 127 forks source link

Support currency pairs (e.g. EUR/USD) #4

Open wjcrowcroft opened 12 years ago

wjcrowcroft commented 12 years ago

A cool potential feature, logged for later - use money.js to get the rate for any given currency pair - if it wouldn't bloat the code too much

// Something like:
fx("EUR/USD").get() // 1.2945

// or:
fx.pair("GBP/AED") // 5.6974

If anyone has thoughts on that, you know what to do.

thewarpaint commented 11 years ago

Hell, that would be terrific. And it would be perfect if money.js had a set method in that style, for example:

fx("EUR/MXN").set(12.345678)

This is useful because sometimes I let the user input the exchange rate of an arbitrary currency pair, and I have to manually convert the rate to the base since I'm using the Forever Free plan of OpenExchangeRates, and I cannot change the base currency.

thewarpaint commented 11 years ago

On second thought, I don't think what I just said is possible without assuming only one of the currencies exchange rate (relative to the base currency) is left unchanged.