mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 05:57:04 +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) {
|
||||
for (const key in defaults) {
|
||||
if (!Object.prototype.hasOwnProperty.call(config, key)) {
|
||||
// @ts-ignore
|
||||
config[key] = defaults[key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as redis from 'redis';
|
||||
import { CacheOptions } from "@ajayyy/lru-diskcache";
|
||||
|
||||
export interface SBSConfig {
|
||||
[index: string]: any
|
||||
port: number;
|
||||
mockPort?: number;
|
||||
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;
|
||||
|
||||
// holds the promise results
|
||||
@@ -22,8 +22,8 @@ export function createMemoryCache(memoryFn: (...args: any[]) => void, cacheTimeM
|
||||
}
|
||||
}
|
||||
// create new promise
|
||||
const promise = new Promise(async (resolve) => {
|
||||
resolve((await memoryFn(...args)));
|
||||
const promise = new Promise((resolve) => {
|
||||
resolve(memoryFn(...args));
|
||||
});
|
||||
// store promise reference until fulfilled
|
||||
promiseMemory.set(cacheKey, promise);
|
||||
|
||||
Reference in New Issue
Block a user