From eacdf8a8aa8ac50bb2bad9e54f6f0edc17a902fa Mon Sep 17 00:00:00 2001 From: Jan Litzenburger Date: Tue, 4 Jun 2024 15:32:59 +0200 Subject: [PATCH] Update yahoo-finance2 dependency --- MMM-Jast.js | 2 +- node_helper.js | 4 ++-- package.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MMM-Jast.js b/MMM-Jast.js index d750f16..3fa96ae 100644 --- a/MMM-Jast.js +++ b/MMM-Jast.js @@ -1,6 +1,6 @@ /*! ***************************************************************************** mmm-jast - Version 2.9.4 + Version 2.9.5 A minimalistic stock ticker based on Yahoo's finance API for the MagicMirror² platform. Please submit bugs at https://github.com/jalibu/MMM-Jast/issues diff --git a/node_helper.js b/node_helper.js index 747c9d3..4bbaa3d 100644 --- a/node_helper.js +++ b/node_helper.js @@ -1,6 +1,6 @@ /*! ***************************************************************************** mmm-jast - Version 2.9.4 + Version 2.9.5 A minimalistic stock ticker based on Yahoo's finance API for the MagicMirror² platform. Please submit bugs at https://github.com/jalibu/MMM-Jast/issues @@ -11,4 +11,4 @@ This file is auto-generated. Do not edit. ***************************************************************************** */ -"use strict";var e=require("node_helper"),r=require("logger"),t=require("yahoo-finance2");function s(e){return e&&e.__esModule?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var o=n(e),a=n(r),i=s(t);function c(e,r,t,s){return new(t||(t=Promise))((function(n,o){function a(e){try{c(s.next(e))}catch(e){o(e)}}function i(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(a,i)}c((s=s.apply(e,r||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class u{static requestStocks(e){var r;return c(this,void 0,void 0,(function*(){const t=[],s=[];for(const r of e.stocks)s.push(i.default.quoteSummary(r.symbol,{modules:["price"]}));const n=yield Promise.all(s.map((e=>e.catch((e=>e)))));for(const[s,o]of n.entries())if(o instanceof Error)a.warn(`API request for ${e.stocks[s].symbol} failed:`,o.message);else if(o.price){const n={symbol:e.stocks[s].symbol,name:e.stocks[s].name,quantity:e.stocks[s].quantity,hidden:e.stocks[s].hidden,purchasePrice:e.stocks[s].purchasePrice};if("GBp"===o.price.currency&&(o.price.regularMarketPrice/=100,o.price.regularMarketChange/=100,o.price.currency="GBP"),e.maxChangeAge>0){const t=(new Date).getTime()-e.maxChangeAge;try{t>Date.parse(o.price.regularMarketTime)&&(o.price.regularMarketPreviousClose=null===(r=o.price)||void 0===r?void 0:r.regularMarketPrice,o.price.regularMarketChange=0,o.price.regularMarketChangePercent=0)}catch(e){a.warn("Could not parse lastChange date",e)}}t.push({price:o.price,meta:n})}else a.warn(`Response for ${e.stocks[s].symbol} does not satisfy expected payload.`);return t}))}}const l=["regularMarketChange","regularMarketChangePercent","regularMarketPrice","currency","longName","regularMarketPreviousClose"];module.exports=o.create({start(){a.log(`${this.name} helper method started...`)},socketNotificationReceived(e,r){return c(this,void 0,void 0,(function*(){if(e.includes("JAST_STOCKS_REQUEST")){const t=e.substring(20);let s=yield u.requestStocks(r);s=s.filter((e=>l.every((r=>!!Object.prototype.hasOwnProperty.call(e.price,r)||(a.warn(`Skipped symbol '${e.meta.symbol}' as it's response did not have required property '${r}'. This is usually the case when a symbol is misspelled`),!1)))));const n={lastUpdate:Date.now(),stocks:s};this.sendSocketNotification(`JAST_STOCKS_RESPONSE-${t}`,n)}else a.warn(`${e} is invalid notification`)}))}}); +"use strict";var e=require("node_helper"),r=require("logger"),t=require("yahoo-finance2");function s(e){return e&&e.__esModule?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var o=n(e),a=n(r),i=s(t);function c(e,r,t,s){return new(t||(t=Promise))((function(n,o){function a(e){try{c(s.next(e))}catch(e){o(e)}}function i(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(a,i)}c((s=s.apply(e,r||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class u{static requestStocks(e){return c(this,void 0,void 0,(function*(){var r;const t=[],s=[];for(const r of e.stocks)s.push(i.default.quoteSummary(r.symbol,{modules:["price"]}));const n=yield Promise.all(s.map((e=>e.catch((e=>e)))));for(const[s,o]of n.entries())if(o instanceof Error)a.warn(`API request for ${e.stocks[s].symbol} failed:`,o.message);else if(o.price){const n={symbol:e.stocks[s].symbol,name:e.stocks[s].name,quantity:e.stocks[s].quantity,hidden:e.stocks[s].hidden,purchasePrice:e.stocks[s].purchasePrice};if("GBp"===o.price.currency&&(o.price.regularMarketPrice/=100,o.price.regularMarketChange/=100,o.price.currency="GBP"),e.maxChangeAge>0){const t=(new Date).getTime()-e.maxChangeAge;try{t>Date.parse(o.price.regularMarketTime)&&(o.price.regularMarketPreviousClose=null===(r=o.price)||void 0===r?void 0:r.regularMarketPrice,o.price.regularMarketChange=0,o.price.regularMarketChangePercent=0)}catch(e){a.warn("Could not parse lastChange date",e)}}t.push({price:o.price,meta:n})}else a.warn(`Response for ${e.stocks[s].symbol} does not satisfy expected payload.`);return t}))}}const l=["regularMarketChange","regularMarketChangePercent","regularMarketPrice","currency","longName","regularMarketPreviousClose"];module.exports=o.create({start(){a.log(`${this.name} helper method started...`)},socketNotificationReceived(e,r){return c(this,void 0,void 0,(function*(){if(e.includes("JAST_STOCKS_REQUEST")){const t=e.substring(20);let s=yield u.requestStocks(r);s=s.filter((e=>l.every((r=>!!Object.prototype.hasOwnProperty.call(e.price,r)||(a.warn(`Skipped symbol '${e.meta.symbol}' as it's response did not have required property '${r}'. This is usually the case when a symbol is misspelled`),!1)))));const n={lastUpdate:Date.now(),stocks:s};this.sendSocketNotification(`JAST_STOCKS_RESPONSE-${t}`,n)}else a.warn(`${e} is invalid notification`)}))}}); diff --git a/package.json b/package.json index 4f2758c..3ae2866 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mmm-jast", - "version": "2.9.4", + "version": "2.9.5", "description": "A minimalistic stock ticker based on Yahoo's finance API for the MagicMirror² platform.", "main": "MMM-Jast.js", "repository": { @@ -27,7 +27,7 @@ }, "homepage": "https://github.com/jalibu/MMM-Jast#readme", "dependencies": { - "yahoo-finance2": "^2.11.2" + "yahoo-finance2": "^2.11.3" }, "scripts": { "build": "rollup -c --bundleConfigAsCjs",