forked from openexchangerates/money.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
money.min.js
4 lines (4 loc) · 1.08 KB
/
money.min.js
1
2
3
4
/* money.js 0.0.1 - josscrowcroft.github.com/money.js */
(function(g,j){var a=function(a){return new i(a)};a.version="0.0.1";var c=g.fxSetup||{rates:{},base:"USD"};a.rates=c.rates;a.base=c.base;a.settings={from:c.from||a.base,to:c.to||a.base};var h=a.convert=function(b,e){if(typeof b==="object"&&b.length){for(var d=0;d<b.length;d++)b[d]=h(b[d],e);return b}e=e||{};if(!e.from)e.from=a.settings.from;if(!e.to)e.to=a.settings.to;var d=e.to,c=e.from,f=a.rates;if(!f[c]||!f[d])throw"fx error";d=c===a.base?f[d]:d===a.base?1/f[c]:f[d]*(1/f[c]);return b*d},i=function(a){this._v=
a},c=a.prototype=i.prototype;c.convert=function(){var b=Array.prototype.slice.call(arguments);b.unshift(this._v);return h.apply(a,b)};c.from=function(b){b=a(h(this._v,{from:b,to:a.base}));b._fx=a.base;return b};c.to=function(b){return h(this._v,{from:this._fx?this._fx:a.settings.from,to:b})};typeof module!=="undefined"&&module.exports?(module.exports=a,a.fx=a):typeof define==="function"&&define.amd?define([],function(){return a}):(a.noConflict=function(b){return function(){g.fx=b;a.noConflict=j;return a}}(g.fx),
g.fx=a)})(this);