Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into mute-skip

This commit is contained in:
Ajay Ramachandran
2021-07-05 13:29:26 -04:00
11 changed files with 22 additions and 18 deletions

View File

@@ -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);

View File

@@ -8,6 +8,7 @@ if (config.diskCache) {
DiskCache.init();
} else {
DiskCache = {
/* eslint-disable @typescript-eslint/no-unused-vars */
// constructor(rootPath, options): {};
init(): void { return; },
@@ -16,16 +17,17 @@ if (config.diskCache) {
has(key: string): boolean { return false; },
get(key: string, opts): string { return null; },
get(key: string, opts?: {encoding?: string}): string { return null; },
// Returns size
set(key: string, dataOrSteam): Promise<number> { return new Promise(() => 0); },
set(key: string, dataOrSteam: string): Promise<number> { return new Promise(() => 0); },
del(key: string): void { return; },
size(): number { return 0; },
prune(): void {return; },
/* eslint-enable @typescript-eslint/no-unused-vars */
};
}