From 5d346ba7fbb5c03cee6b52c48bf29169a6c4502f Mon Sep 17 00:00:00 2001 From: Evorp <3vorpgaming@gmail.com> Date: Mon, 15 Jan 2024 17:37:34 -0800 Subject: [PATCH] eslint --- .../repository/firestorm/packs.repository.ts | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/v2/repository/firestorm/packs.repository.ts b/src/v2/repository/firestorm/packs.repository.ts index 9e4d2d4..77085fa 100644 --- a/src/v2/repository/firestorm/packs.repository.ts +++ b/src/v2/repository/firestorm/packs.repository.ts @@ -76,23 +76,25 @@ export default class PackFirestormRepository implements PackRepository { criteria: "==", value: resolution, }); - const prom: Promise = options.length + const searchPromise: Promise = options.length ? packs.search(options) : packs.readRaw().then(Object.values); - return prom.then(async (packs) => { - if (!type || type === "all") return packs; - const out: Packs = []; - for (const pack of packs) { - try { - await pack.submission(); - } catch { - out.push(pack); - } - } + return searchPromise.then(async (searched) => { + if (!type || type === "all") return searched; + const out = ( + await Promise.all( + searched.map((pack) => + pack + .submission() + .then(() => pack) + .catch(() => undefined), + ), + ) + ).filter((v) => v !== undefined); - if (type === "default") return out; - return packs.filter((p) => !out.includes(p)); + if (type === "submission") return out; + return searched.filter((p) => !out.includes(p)); }); }