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/open-exchange-rates@0.3.0/open-exchange-rates.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/open-exchange-rates@0.3.0/open-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-exchange-rates npm module - v0.3\n * by Open Exchange Rates - https://openexchangerates.org\n *\n * nodeJS/npm wrapper for the Open Exchange Rates API.\n * Sign up for an API App ID here: https://openexchangerates.org/signup\n *\n * Requires: http-agent\n *\n * Basic Usage:\n *     var oxr = require('open-exchange-rates');\n *     oxr.set({app_id: 'YOUR_APP_ID'});\n *     oxr.latest(function(error) {\n *         // `error` or `oxr.error` contains debug info\n *         // if no error, `oxr.rates` and `oxr.base` are available\n *     });\n *\n * See example.js for full usage example.\n * See readme.md for advanced queries and usage.\n */\n\n(function() {\n\tvar oxr = {};\n\n\t/* Library settings */\n\n\t// Module version:\n\toxr.version = '0.3';\n\n\t// API base URL:\n\toxr.api_url = 'http://openexchangerates.org/api/'\n\n\t// The default base currency ('USD'):\n\toxr.base = 'USD';\n\n\t// The rates object:\n\toxr.rates = {};\n\n\t// If something goes wrong, details will be stored in `oxr.error`:\n\toxr.error = '';\n\n\n\t/* Library methods */\n\n\t// Sets API module parameters:\n\t// Currently only app_id is implemented (advanced parameters in roadmap)\n\toxr.set = function(opts) {\n\t\toxr.app_id = opts.app_id;\n\t\treturn oxr;\n\t}\n\n\t// Loads `latest.json` (latest rates)\n\toxr.latest = function(callback) {\n\t\toxr.load('latest.json', callback);\n\t\treturn oxr;\n\t}\n\n\t// Loads `historical/yyyy-mm-dd.json` (historical rates)\n\t// `date` must be in format `'YYYY-MM-DD'`, e.g. `'2001-12-31'`\n\toxr.historical = function(date, callback) {\n\t\toxr.load('historical/' + date + '.json', callback);\n\t\treturn oxr;\n\t}\n\n\t// Loads exchange rates from the Open Exchange Rates API:\n\t// `path` is optional (default `'latest.json'`)\n\t// `callback` is required (see readme.md and example.js)\n\toxr.load = function(path, callback) {\n\t\t// Default parameters:\n\t\tif (typeof path === 'function') callback = path;\n\t\tpath = (typeof path === 'string') ? path : 'latest.json';\n\n\t\t// Build API URL\n\t\tvar url = oxr.api_url + path + '?app_id=' + oxr.app_id;\n\n\t\t// Create the http-agent that will grab the data:\n\t\tvar agent = require('http-agent').create('', [{\n\t\t\tmethod: 'GET',\n\t\t\turi: url\n\t\t}]);\n\n\t\tagent.addListener('next', function (err, agent) {\n\t\t\tvar data = (agent && agent.body) ? agent.body : null;\n\t\t\toxr.error = err;\n\n\t\t\t// Parse the API response:\n\t\t\tif ( !oxr.error ) {\n\t\t\t\toxr.parse.call(oxr, data, oxr);\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(oxr.error, data);\n\t\t\t}\n\t\t});\n\n\t\t// Start http-agent:\n\t\tagent.start();\n\t\treturn oxr;\n\t};\n\n\t// The parse callback function takes the raw API data and parses/validates it.\n\toxr.parse = function(data, oxr) {\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\toxr.error = 'Module error in parsing JSON data: ' + err.toString();\n\t\t\treturn oxr;\n\t\t}\n\n\t\t// If the API returned an error message:\n\t\tif ( data && data.error ) {\n\t\t\t// Create debug message from API error:\n\t\t\toxr.error = data.status + ' (' + data.message + '): ' + data.description;\n\t\t\treturn oxr;\n\t\t}\n\n\t\t// The standard API response contains the base currency, an object of\n\t\t// exchange rates, and the timestamp of when the rates were published:\n\t\tif ( data && data.base && data.rates ) {\n\t\t\toxr.base = data.base;\n\t\t\toxr.rates = data.rates;\n\t\t\toxr.timestamp = data.timestamp * 1000; // (unix to ms)\n\t\t} else {\n\t\t\toxr.error = 'No rates or base currency returned from API';\n\t\t}\n\n\t\treturn oxr;\n\t};\n\n\t// Export the library module:\n\tmodule.exports = oxr;\n\n}())\n"]}