{"version":3,"sources":["jsdelivr-header.js","/npm/exchange-rates@0.1.2/exchange-rates.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,CC4BC,WACA,IAAI,EAAW,CAGf,QAAmB,QAGnB,IAAe,2CAGf,KAAgB,SAAS,EAAK,GACV,mBAAR,IAAoB,EAAW,GAC1C,EAAsB,iBAAR,EAAoB,EAAM,EAAS,IAGjD,IAAI,EAAQ,QAAQ,cAAc,OAAO,GAAI,CAAC,CAAC,OAAQ,MAAO,IAAK,KACnE,EAAM,YAAY,QAAQ,SAAU,EAAK,GACxC,IAAI,EAAQ,GAAS,EAAM,KAAQ,EAAM,KAAO,KAChD,EAAS,MAAQ,EAGX,GACL,EAAS,MAAM,KAAK,EAAU,EAAM,GAIZ,mBAAb,GACX,EAAS,EAAS,MAAO,EAE3B,IAGA,EAAM,OACP,EAGA,MAAiB,CAAC,EAClB,KAAgB,GAGhB,MAAiB,GAMjB,MAAiB,SAAS,EAAM,GAG/B,IACC,EAAO,KAAK,MAAM,EACnB,CAAE,MAAM,GAEP,OADA,EAAS,MAAQ,qCAAuC,EAAI,WACrD,CACR,CAaA,OATK,GAAQ,EAAK,MAAQ,EAAK,OAC9B,EAAS,KAAO,EAAK,KACrB,EAAS,MAAQ,EAAK,MACtB,EAAS,UAA6B,IAAjB,EAAK,WAE1B,EAAS,MAAQ,8CAIX,CACR,GAGA,OAAO,QAAU,CAClB,CAxEA","file":"/npm/exchange-rates@0.1.2/exchange-rates.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/exchange-rates@0.1.2/exchange-rates.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Open Source Exchange Rates API - nodeJS/npm module - v0.1.2\n * by Joss Crowcroft | http://www.josscrowcroft.com\n *\n * NB: This module has been DEPRECATED and REPLACED by the improved\n * 'open-exchange-rates' module (https://npmjs.org/package/open-exchange-rates)\n *\n * It's highly recommended that you use that one instead! (This module will no\n * longer work, unless you modify it to include an `app_id` with your requests.\n *\n * ---\n *\n * Loads up-to-date exchange rate data from the https://openexchangerates.org API\n * or any other service. Doesn't mind what format you need the exchange rates\n * in or where you get them from. Easy to override post-receive parsing method.\n *\n * Requires: http-agent\n *\n * Usage:\n *     var exchange = require(\"exchange-rates\");\n *     exchange.load([url], function(error, data) {\n *         // if no `error`, `exchange.rates` and `exchange.base` are available\n *         // `error` is the same as `exchange.error` and contains debug info\n *         // `data` is the raw response that was passed to `exchange.parse`\n *     });\n *\n * Define your own `exchange.parse` if needed for another API or service.\n *\n * Params:\n * `url` is optional, defaults to 'http://openexchangerates.org/latest.json'\n * (specify another to load rates from a different service or local file)\n * `callback` function is only executed async once the rates have been loaded.\n */\n\n(function() {\n\tvar exchange = {};\n\n\t// Module version:\n\texchange.version = \"0.1.1\";\n\n\t// Default API URL, loads data from the Open Exchange Rates project:\n\texchange.url = \"http://openexchangerates.org/latest.json\"\n\n\t// Loads exchange rates from a given URL (default `exchange.url`):\n\texchange.load = function(url, callback) {\n\t\tif (typeof url === \"function\") callback = url;\n\t\turl = (typeof url === \"string\") ? url : exchange.url;\n\n\t\t// Create the http agent that will grab the data:\n\t\tvar agent = require(\"http-agent\").create('', [{method: 'GET', uri: url}]);\n\t\tagent.addListener('next', function (err, agent) {\n\t\t\tvar data = (agent && agent.body) ? agent.body : null;\n\t\t\texchange.error = err;\n\n\t\t\t// Parse the API response:\n\t\t\tif ( !err ) {\n\t\t\t\texchange.parse.call(exchange, data, exchange);\n\t\t\t}\n\n\t\t\t// Fire callback function, passing in any error and the raw data:\n\t\t\tif ( typeof callback === \"function\" ) {\n\t\t\t\tcallback(exchange.error, data);\n\t\t\t}\n\t\t});\n\n\t\t// Start http-agent:\n\t\tagent.start();\n\t};\n\n\t// The rates object and base currency:\n\texchange.rates = {};\n\texchange.base = \"\";\n\n\t// If something went wrong, you'll hear about it via `exchange.error`\n\texchange.error = \"\";\n\n\t// The parse callback function takes the raw API data and parses/validates it.\n\t// Default implementation is designed for the openexchangerates.org API data.\n\t// Replace with custom parsing/validation logic for other APIs or as required.\n\t// NB: `this` refers to the module object (also referenced in 2nd argument)\n\texchange.parse = function(data, exchange) {\n\n\t\t// Try to parse the data as JSON:\n\t\ttry {\n\t\t\tdata = JSON.parse(data);\n\t\t} catch(err) {\n\t\t\texchange.error = \"Error in parsing JSON rates data: \" + err.toString();\n\t\t\treturn exchange;\n\t\t}\n\n\t\t// The Open Exchange Rates API response object contains the base currency,\n\t\t// an exchange rates hash and the unix time when the rates were collected:\n\t\tif ( data && data.base && data.rates ) {\n\t\t\texchange.base = data.base;\n\t\t\texchange.rates = data.rates;\n\t\t\texchange.timestamp = data.timestamp * 1000;\n\t\t} else {\n\t\t\texchange.error = \"No rates or base currency returned from API\";\n\t\t}\n\n\t\t// exchange.parse\n\t\treturn exchange;\n\t};\n\n\t// Export the module:\n\tmodule.exports = exchange;\n}())\n"]}