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

faster-query

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

faster-query - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

2

dist/index.d.ts

@@ -78,4 +78,4 @@ /// <reference types="node" />

private log;
static clearTimers(code: number): void;
static clearTimers(code?: number): void;
}
export default FasterQuery;

@@ -173,6 +173,6 @@ "use strict";

this.log(`SCHEDULED UPDATE: ${fn.name}(${args})`, ttl, FasterQuery.timersToUpdate.keys());
FasterQuery.timersToUpdate.set(key, setInterval(() => __awaiter(this, void 0, void 0, function* () {
this.log(`UPDATED DATA IN SCHEDULE: ${fn.name}(${args})`, `every (${ttl}-2) sec`);
yield this.executeFunctionAndWriteCache(fn, args);
}), (ttl - 2) * 1000));
FasterQuery.timersToUpdate.set(key, setTimeout(() => {
this.log(`UPDATED DATA IN SCHEDULE: ${fn.name}(${args})`, `every (${ttl}-2) sec`, key);
this.executeFunctionAndWriteCache(fn, args);
}, (ttl - 2) * 1000));
}

@@ -233,3 +233,3 @@ }

static isDebugging() {
return process.env.NODE_ENV === 'development' || FasterQuery.isLogging;
return process.env.NODE_ENV === 'development' && FasterQuery.isLogging;
}

@@ -240,3 +240,3 @@ log(...args) {

}
static clearTimers(code) {
static clearTimers(code = 0) {
if (FasterQuery.isDebugging()) {

@@ -259,4 +259,4 @@ console.log('CACHED:V2 DEBUG: EXITTING APP WITH CODE: ', code);

FasterQuery.timersToDelete = new Map();
FasterQuery.isLogging = false;
FasterQuery.isLogging = true;
process.on('exit', FasterQuery.clearTimers);
exports.default = FasterQuery;
{
"name": "faster-query",
"version": "2.0.3",
"version": "2.0.4",
"description": "Faster query for any slow function. Get any data from cache and update in cache AFTER data is received",

@@ -20,3 +20,3 @@ "types": "dist/index.d.ts",

"main": "./dist/index.js",
"repository": "https://github.com/Jsox/faster-query",
"repository": "https://github.com/Jsox/incremental-static-regeneration-for-any-data",
"author": "Eugene Yakunin <admin@jsix.ru> (https://jsix.ru)",

@@ -23,0 +23,0 @@ "license": "BSD-3-Clause",

@@ -27,3 +27,3 @@ import * as fs from 'fs';

static timersToDelete = new Map<string, NodeJS.Timeout>();
static isLogging = false;
static isLogging = true;

@@ -90,11 +90,11 @@ /**

try {
await writeFile(
`${this.cachePath}/${key}.json`,
JSON.stringify(data),
'utf8',
);
} catch (error) {
console.error('Error deleting cache:', error);
await writeFile(
`${this.cachePath}/${key}.json`,
JSON.stringify(data),
'utf8',
);
} catch (error) {
console.error('Error deleting cache:', error);
}
}
}

@@ -170,12 +170,16 @@ /**

);
FasterQuery.timersToUpdate.set(key, setInterval(
async () => {
this.log(
`UPDATED DATA IN SCHEDULE: ${fn.name}(${args})`,
`every (${ttl}-2) sec`,
);
await this.executeFunctionAndWriteCache(fn, args);
},
(ttl - 2) * 1000,
));
FasterQuery.timersToUpdate.set(
key,
setTimeout(
() => {
this.log(
`UPDATED DATA IN SCHEDULE: ${fn.name}(${args})`,
`every (${ttl}-2) sec`,
key,
);
this.executeFunctionAndWriteCache(fn, args);
},
(ttl - 2) * 1000,
),
);
}

@@ -251,3 +255,3 @@ }

static isDebugging(): boolean {
return process.env.NODE_ENV === 'development' || FasterQuery.isLogging;
return process.env.NODE_ENV === 'development' && FasterQuery.isLogging;
}

@@ -257,6 +261,10 @@

if (FasterQuery.isDebugging())
console.log(new Date().toLocaleString(), 'CACHED:V2 DEBUG: ', ...args);
console.log(
new Date().toLocaleString(),
'CACHED:V2 DEBUG: ',
...args,
);
}
static clearTimers(code: number) {
static clearTimers(code: number = 0) {
if (FasterQuery.isDebugging()) {

@@ -269,8 +277,9 @@ console.log('CACHED:V2 DEBUG: EXITTING APP WITH CODE: ', code);

}
FasterQuery.timersToUpdate.forEach((timer) => {
clearInterval(timer);
})
});
FasterQuery.timersToDelete.forEach((timer) => {
clearTimeout(timer);
})
});
}

@@ -277,0 +286,0 @@ }

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