mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-17 21:18:47 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer into mute-skip
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user