Socket
Socket
Sign inDemoInstall

@swapbills/xchange-rate

Package Overview
Dependencies
74
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.6 to 1.1.8

lib/xchange-service.spec.js

51

lib/xchange-service.js

@@ -42,6 +42,6 @@ 'use strict';

this._API_BASE = 'https://www.google.com/finance/';
this._API_BASE = 'https://finance.google.com/finance/';
this._paths = {
converter: 'converter?a=1&from=',
chart: 'getchart?x=CURRENCY&p=1Y&i=86400&q='
converter: 'converter', // ?a=1&from`,
chart: 'getchart' // ?x=CURRENCY&p=1Y&i=86400&q=`
};

@@ -59,5 +59,5 @@ }

}, {
key: 'makeGetRequest',
key: 'getFromRemote',
value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(path) {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(options) {
return _regenerator2.default.wrap(function _callee$(_context) {

@@ -68,4 +68,4 @@ while (1) {

return _context.abrupt('return', new Promise(function (resolve, reject) {
(0, _request2.default)(path, function (error, resp, body) {
return error ? reject(error) : resolve(body ? body : resp);
(0, _request2.default)(options, function (error, resp, body) {
return error ? reject(error) : resolve(body || resp);
});

@@ -82,7 +82,7 @@ }));

function makeGetRequest(_x) {
function getFromRemote(_x) {
return _ref.apply(this, arguments);
}
return makeGetRequest;
return getFromRemote;
}()

@@ -92,3 +92,3 @@ }, {

value: function () {
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(baseCurrency, destCurrency) {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(baseCurrency, destCurrency) {
var proxyUrl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';

@@ -100,17 +100,22 @@ var path;

case 0:
path = '' + proxyUrl + this.getUri('converter') + baseCurrency + '&to=' + destCurrency;
_context2.next = 3;
return this.makeGetRequest(path).then(function (body) {
path = '' + proxyUrl + this.getUri('converter'); // `${baseCurrency}&to=${destCurrency}`
return _context2.abrupt('return', this.getFromRemote({
url: path,
qs: { a: '1', from: baseCurrency, to: destCurrency },
headers: {
'swapBills-token': Date.now(),
'postman-token': '2cdab2a1-a6ef-33ec-7509-0ab90de6f802',
'cache-control': 'no-cache'
}
}).then(function (body) {
var $ = _cheerio2.default.load(body);
var html = $('#currency_converter_result .bld').html();
if (html.indexOf(' ')) {
if (html && html.indexOf(' ') > -1) {
return parseFloat(html.split(' ')[0]);
}
throw new Error('InvalidDataReceived');
});
}));
case 3:
return _context2.abrupt('return', _context2.sent);
case 4:
case 2:
case 'end':

@@ -132,3 +137,3 @@ return _context2.stop();

value: function () {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3() {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
return _regenerator2.default.wrap(function _callee3$(_context3) {

@@ -157,3 +162,3 @@ while (1) {

value: function () {
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(query) {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(query) {
return _regenerator2.default.wrap(function _callee4$(_context4) {

@@ -185,3 +190,3 @@ while (1) {

value: function () {
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(baseCurrency, destCurrency) {
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(baseCurrency, destCurrency) {
var proxyUrl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';

@@ -192,3 +197,3 @@ return _regenerator2.default.wrap(function _callee5$(_context5) {

case 0:
return _context5.abrupt('return', '' + proxyUrl + this.getUri('chart') + baseCurrency.toUpperCase() + destCurrency.toUpperCase());
return _context5.abrupt('return', '' + proxyUrl + this.getUri('chart') + '?x=CURRENCY&p=1Y&i=86400&q=' + baseCurrency.toUpperCase() + destCurrency.toUpperCase());

@@ -195,0 +200,0 @@ case 1:

{
"name": "@swapbills/xchange-rate",
"version": "1.1.6",
"version": "1.1.8",
"description": "A simple wrapper around google finance API for retrieving the exchange rate between two currencies, use at your own risk.",

@@ -24,7 +24,10 @@ "main": "lib/index.js",

"start": "babel-node src/index.js & npm run watch",
"test": "mocha --compilers js:babel-core/register --require babel-polyfill",
"lint": "eslint src",
"build": "babel -d lib/ src/ ; cp src/data.json lib/data.json",
"test": "nyc ava",
"lint": "./node_modules/.bin/standard",
"lint:fix": "./node_modules/.bin/standard --fix",
"build": "npm run clean; npm run lint && npm run test && babel -d lib/ src/; cp src/data.json lib/data.json",
"watch": "onchange './src/*' -- npm run type:check",
"type:check": "flow check"
"type:check": "flow check",
"postversion": "git push origin --tags",
"clean": "rm -rf lib"
},

@@ -35,5 +38,6 @@ "files": [

"devDependencies": {
"ava": "^0.22.0",
"babel-cli": "^6.4.5",
"babel-core": "^6.4.5",
"babel-eslint": "^4.1.8",
"babel-eslint": "^8.0.0",
"babel-plugin-transform-flow-strip-types": "^6.4.0",

@@ -44,14 +48,48 @@ "babel-plugin-transform-runtime": "^6.23.0",

"babel-preset-stage-0": "^6.3.13",
"chai": "^3.5.0",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^4.0.0",
"babel-runtime": "^6.26.0",
"flow-bin": "^0.22.0",
"mocha": "^2.4.5",
"onchange": "^2.0.0"
"nock": "^9.0.14",
"nyc": "^11.2.1",
"onchange": "^2.0.0",
"standard": "^10.0.3"
},
"dependencies": {
"babel-runtime": "^6.23.0",
"cheerio": "^0.22.0",
"request": "^2.81.0"
},
"ava": {
"files": [
"**/**.spec.js",
"!src/index.js",
"!dist/**/*"
],
"require": [
"babel-register"
],
"concurrency": 10,
"babel": {
"babelrc": true,
"sourceMaps": "inline"
}
},
"nyc": {
"check-coverage": true,
"lines": 100,
"statements": 100,
"functions": 100,
"branches": 100,
"exclude": [
"dist/**/*",
"**/*.spec.js"
],
"reporter": [
"html",
"lcov",
"text"
]
},
"standard": {
"parser": "babel-eslint"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc