New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gbridge0/homebridge-ambient-weather-sensors

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gbridge0/homebridge-ambient-weather-sensors - npm Package Compare versions

Comparing version 1.2.7 to 1.2.8

2

dist/cache.d.ts

@@ -7,3 +7,3 @@ import { Logger } from 'homebridge';

private valid;
private cache_data;
private cachedData;
constructor(CacheFile: string, ttl: number, log: Logger);

@@ -10,0 +10,0 @@ write(data: any): void;

@@ -14,3 +14,3 @@ "use strict";

this.valid = false;
this.cache_data = {
this.cachedData = {
cache_time: Date.now(),

@@ -30,3 +30,3 @@ ttl: this.ttl,

try {
this.cache_data = cache;
this.cachedData = cache;
fs_1.default.writeFileSync(this.CacheFile, JSON.stringify(cache));

@@ -48,9 +48,10 @@ }

try {
if (this.cache_data !== undefined) {
return this.cache_data;
// return cached data if data element is not empty
if (this.cachedData.data.length > 0) {
return this.cachedData;
}
this.log.debug('Reading API response from DISK cache');
this.log.debug('Reading API response from DISK cache and populating in memory cache');
const data = fs_1.default.readFileSync(this.CacheFile, 'utf8');
const json = JSON.parse(data);
this.cache_data = json;
this.cachedData = json;
return json;

@@ -74,3 +75,2 @@ }

const now = Date.now();
// use dynamic TTL
this.valid = now - cache.cache_time < this.ttl;

@@ -77,0 +77,0 @@ }

@@ -101,2 +101,6 @@ "use strict";

const response = await (0, node_fetch_1.default)(url);
// check if the response code is 200
if (response.status !== 200) {
throw new Error(`Received unexpected response code: ${response.status}`);
}
const json = await response.json();

@@ -179,6 +183,6 @@ this.Cache.write(json);

}
// load from remote API every 2 minutes
this.log.debug('Setting up interval to fetch sensors from remote API every 2 minutes');
setInterval(this.fetchDevicesFromAPI.bind(this), 2 * 60 * 1000);
}
// load from remote API every 2 minutes
this.log.debug('Setting up interval to fetch sensors from remote API every 2 minutes');
setInterval(this.fetchDevicesFromAPI.bind(this), 2 * 60 * 1000);
}

@@ -185,0 +189,0 @@ catch (error) {

@@ -5,3 +5,3 @@ {

"name": "@gbridge0/homebridge-ambient-weather-sensors",
"version": "1.2.7",
"version": "1.2.8",
"description": "Utilizes the ambient weather API to retrie sensor information.",

@@ -8,0 +8,0 @@ "license": "Apache-2.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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