Consider using "forEach" instead of "map" as its return value is not being used here.
Replace this trivial promise with "Promise.resolve".
This commit is contained in:
SashaXser 2024-01-19 08:50:45 +04:00 committed by GitHub
parent 8e13ec60d6
commit 14b6f84f94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 17 deletions

View file

@ -131,21 +131,21 @@ export async function getVideoBrandingByHash(videoHashPrefix: VideoIDHash, servi
};
};
(await branding.titles).map((title) => {
(await branding.titles).forEach((title) => {
title.title = title.title.replace("<", "");
initResult(title);
dbResult[title.videoID].titles.push(title);
});
(await branding.thumbnails).map((thumbnail) => {
(await branding.thumbnails).forEach((thumbnail) => {
initResult(thumbnail);
dbResult[thumbnail.videoID].thumbnails.push(thumbnail);
});
(await branding.segments).map((segment) => {
(await branding.segments).forEach((segment) => {
initResult(segment);
dbResult[segment.videoID].segments.push(segment);
});
});
return dbResult;
}, brandingHashKey(videoHashPrefix, service));

View file

@ -23,9 +23,7 @@ export function createMemoryCache(memoryFn: (...args: any[]) => void, cacheTimeM
}
}
// create new promise
const promise = new Promise((resolve) => {
resolve(memoryFn(...args));
});
const promise = Promise.resolve(memoryFn(...args));
// store promise reference until fulfilled
promiseMemory.set(cacheKey, promise);
return promise.then(result => {

View file

@ -26,16 +26,17 @@ interface RedisSB {
}
let exportClient: RedisSB = {
get: () => new Promise((resolve) => resolve(null)),
set: () => new Promise((resolve) => resolve(null)),
setEx: () => new Promise((resolve) => resolve(null)),
del: () => new Promise((resolve) => resolve(null)),
increment: () => new Promise((resolve) => resolve(null)),
sendCommand: () => new Promise((resolve) => resolve(null)),
quit: () => new Promise((resolve) => resolve(null)),
ttl: () => new Promise((resolve) => resolve(null)),
get: () => Promise.resolve(null),
set: () => Promise.resolve(null),
setEx: () => Promise.resolve(null),
del: () => Promise.resolve(null),
increment: () => Promise.resolve(null),
sendCommand: () => Promise.resolve(null),
quit: () => Promise.resolve(null),
ttl: () => Promise.resolve(null),
};
let lastClientFail = 0;
let lastReadFail = 0;
let activeRequests = 0;