mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 22:17:14 +03:00
type config & remove await from memoryCache
This commit is contained in:
@@ -84,7 +84,6 @@ addDefaults(config, {
|
|||||||
function addDefaults(config: SBSConfig, defaults: SBSConfig) {
|
function addDefaults(config: SBSConfig, defaults: SBSConfig) {
|
||||||
for (const key in defaults) {
|
for (const key in defaults) {
|
||||||
if (!Object.prototype.hasOwnProperty.call(config, key)) {
|
if (!Object.prototype.hasOwnProperty.call(config, key)) {
|
||||||
// @ts-ignore
|
|
||||||
config[key] = defaults[key];
|
config[key] = defaults[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import * as redis from 'redis';
|
|||||||
import { CacheOptions } from "@ajayyy/lru-diskcache";
|
import { CacheOptions } from "@ajayyy/lru-diskcache";
|
||||||
|
|
||||||
export interface SBSConfig {
|
export interface SBSConfig {
|
||||||
|
[index: string]: any
|
||||||
port: number;
|
port: number;
|
||||||
mockPort?: number;
|
mockPort?: number;
|
||||||
globalSalt: string;
|
globalSalt: string;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export function createMemoryCache(memoryFn: (...args: any[]) => void, cacheTimeMs: number) {
|
export function createMemoryCache(memoryFn: (...args: any[]) => void, cacheTimeMs: number): any {
|
||||||
if (isNaN(cacheTimeMs)) cacheTimeMs = 0;
|
if (isNaN(cacheTimeMs)) cacheTimeMs = 0;
|
||||||
|
|
||||||
// holds the promise results
|
// holds the promise results
|
||||||
@@ -22,8 +22,8 @@ export function createMemoryCache(memoryFn: (...args: any[]) => void, cacheTimeM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create new promise
|
// create new promise
|
||||||
const promise = new Promise(async (resolve) => {
|
const promise = new Promise((resolve) => {
|
||||||
resolve((await memoryFn(...args)));
|
resolve(memoryFn(...args));
|
||||||
});
|
});
|
||||||
// store promise reference until fulfilled
|
// store promise reference until fulfilled
|
||||||
promiseMemory.set(cacheKey, promise);
|
promiseMemory.set(cacheKey, promise);
|
||||||
|
|||||||
Reference in New Issue
Block a user