seyfert/vendor/rest/cleanupQueues.ts
2022-06-21 20:25:17 -05:00

15 lines
530 B
TypeScript

import { RestManager } from "./restManager.ts";
/** Cleans up the queues by checking if there is nothing left and removing it. */
export function cleanupQueues(rest: RestManager) {
for (const [key, queue] of rest.pathQueues) {
rest.debug(`[REST - cleanupQueues] Running for of loop. ${key}`);
if (queue.requests.length) continue;
// REMOVE IT FROM CACHE
rest.pathQueues.delete(key);
}
// NO QUEUE LEFT, DISABLE THE QUEUE
if (!rest.pathQueues.size) rest.processingQueue = false;
}