Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-stocks-watch

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-stocks-watch - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

.eslintrc

45

dist/google-stocks-watch.js

@@ -18,12 +18,12 @@ 'use strict';

var GoogleStocksWatch = (function () {
function GoogleStocksWatch(_x, callback) {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
function GoogleStocksWatch(options, callback) {
if (options === undefined) options = {};
var _ref$stocks = _ref.stocks;
var stocks = _ref$stocks === undefined ? {} : _ref$stocks;
var _ref$timerInterval = _ref.timerInterval;
var timerInterval = _ref$timerInterval === undefined ? 10000 : _ref$timerInterval;
_classCallCheck(this, GoogleStocksWatch);
var _options$stocks = options.stocks;
var stocks = _options$stocks === undefined ? {} : _options$stocks;
var _options$timerInterval = options.timerInterval;
var timerInterval = _options$timerInterval === undefined ? 10000 : _options$timerInterval;
if (!callback) {

@@ -57,3 +57,3 @@ throw 'google-stocks-watch: callback is not passed';

data.forEach(function (dataObj) {
result.push(_this._onParse(dataObj));
return result.push(_this._onParse(dataObj));
});

@@ -68,3 +68,3 @@

_googleStocks2['default'].get(this._stockCodes, function (error, data) {
(0, _googleStocks2['default'])(this._stockCodes, function (error, data) {
if (error) {

@@ -74,5 +74,3 @@ return _this2._callback(error);

data = _this2._process(data);
_this2._callback(undefined, data);
_this2._callback(undefined, _this2._process(data));
});

@@ -83,12 +81,12 @@ }

value: function _onParse() {
var _ref2 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var code = options.t;
var currentPrice = options.l;
var current_time = options.lt;
var stockCode = _ref2.t;
var currentPrice = _ref2.l;
var currentTime = _ref2.lt;
var _ref = this._stocks[code] || {};
var _ref3 = this._stocks[stockCode] || {};
var stockAmount = _ref.amount;
var initialPrice = _ref.price;
var stockAmount = _ref3.amount;
var initialPrice = _ref3.price;
var currentTotalPrice = currentPrice * stockAmount;

@@ -98,6 +96,8 @@ var purchasedTotalPrice = stockAmount * initialPrice;

var percentage = (difference / purchasedTotalPrice * 100).toFixed(2);
return {
code: stockCode,
code: code,
amount: stockAmount,
current_time: currentTime,
current_time: current_time,
current_price: currentPrice,

@@ -108,3 +108,3 @@ current_total_price: currentTotalPrice.toFixed(2),

diff: difference.toFixed(2),
percentage: (difference / purchasedTotalPrice * 100).toFixed(2) + '%'
percentage: percentage + '%'
};

@@ -142,3 +142,2 @@ }

exports['default'] = GoogleStocksWatch;
;
module.exports = exports['default'];
{
"name": "google-stocks-watch",
"version": "0.1.2",
"version": "0.1.3",
"author": "anvk",

@@ -14,3 +14,9 @@ "main": "dist/google-stocks-watch.js",

"scripts": {
"test": "node node_modules/mocha/bin/mocha --reporter spec test/*"
"lint": "eslint src",
"build:source": "rimraf dist/ && babel src/ --out-dir dist/",
"build:tests": "rimraf test-dist/ && babel test/ --out-dir test-dist/",
"clean": "rimraf dist/ && rimraf test-dist/",
"build": "npm run build:source && npm run build:tests",
"test": "node node_modules/mocha/bin/mocha --reporter spec test-dist/*",
"example": "node example.js"
},

@@ -31,12 +37,13 @@ "directories": {

"dependencies": {
"google-stocks": "0.1.4"
"google-stocks": "0.2.0"
},
"devDependencies": {
"clear": "0.0.1",
"babel": "5.6.5",
"babel-eslint": "5.0.0",
"chai": "3.0.0",
"gulp": "3.9.0",
"gulp-babel": "5.1.0",
"gulp-mocha": "2.1.2",
"mocha": "2.2.5"
"clear": "0.0.1",
"eslint": "2.2.0",
"eslint-config-airbnb": "6.0.2",
"mocha": "2.2.5",
"rimraf": "2.5.2"
},

@@ -43,0 +50,0 @@ "engine": "node >= 0.10.x",

@@ -93,3 +93,3 @@ # google-stocks-watch [![Build Status](https://travis-ci.org/anvk/google-stocks-watch.svg?branch=master)](https://travis-ci.org/anvk/google-stocks-watch)

```
node example.js
npm run example
```

@@ -100,3 +100,1 @@

MIT license; see [LICENSE](./LICENSE).
(c) 2015 by Alexey Novak

@@ -1,3 +0,1 @@

'use strict';
import googleStocks from 'google-stocks';

@@ -7,3 +5,8 @@

constructor({stocks = {}, timerInterval = 10000} = {}, callback) {
constructor(options = {}, callback) {
const {
stocks = {},
timerInterval = 10000
} = options;
if (!callback) {

@@ -30,5 +33,3 @@ throw 'google-stocks-watch: callback is not passed';

// cannot use for...of loop since it is supported only in Node > 0.12
data.forEach(dataObj => {
result.push(this._onParse(dataObj));
});
data.forEach(dataObj => result.push(this._onParse(dataObj)));

@@ -39,3 +40,3 @@ return result;

_tick() {
googleStocks.get(this._stockCodes, (error, data) => {
googleStocks(this._stockCodes, (error, data) => {
if (error) {

@@ -45,18 +46,28 @@ return this._callback(error);

data = this._process(data);
this._callback(undefined, data);
this._callback(undefined, this._process(data));
});
}
_onParse({t: stockCode, l: currentPrice, lt: currentTime} = {}) {
let {amount: stockAmount, price: initialPrice} = this._stocks[stockCode] || {},
currentTotalPrice = currentPrice * stockAmount,
purchasedTotalPrice = stockAmount * initialPrice,
difference = currentTotalPrice - purchasedTotalPrice;
_onParse(options = {}) {
const {
t: code,
l: currentPrice,
lt: current_time
} = options;
const {
amount: stockAmount,
price: initialPrice
} = this._stocks[code] || {};
const currentTotalPrice = currentPrice * stockAmount;
const purchasedTotalPrice = stockAmount * initialPrice;
const difference = currentTotalPrice - purchasedTotalPrice;
const percentage = ((difference / purchasedTotalPrice) * 100).toFixed(2);
return {
code: stockCode,
code,
amount: stockAmount,
current_time: currentTime,
current_time,
current_price: currentPrice,

@@ -67,3 +78,3 @@ current_total_price: currentTotalPrice.toFixed(2),

diff: difference.toFixed(2),
percentage: ((difference / purchasedTotalPrice) * 100).toFixed(2) + '%'
percentage: `${percentage}%`
};

@@ -92,2 +103,2 @@ }

}
};
}

@@ -1,13 +0,5 @@

/* global it, describe, require */
import { expect } from 'chai';
var chai = require('chai'),
expect = chai.expect,
utils = require('../dist/google-stocks-watch.js');
describe('utils tests', function() {
it('meh', function() {
expect(true).to.be.true;
});
describe('utils tests', () => {
it('Need to write proper tests', () => expect(true).to.be.true);
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc