From 6684f3fce6e90fd0574d7bab63b629554ab03ef6 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 20 Nov 2024 13:31:50 +0000 Subject: Prettified Code! --- webAO/utils/filesExist.ts | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'webAO/utils/filesExist.ts') diff --git a/webAO/utils/filesExist.ts b/webAO/utils/filesExist.ts index 2f39427..c41cb2f 100644 --- a/webAO/utils/filesExist.ts +++ b/webAO/utils/filesExist.ts @@ -6,23 +6,25 @@ import fileExists from "./fileExists"; * @param urls the list of URLs to check * @returns either the first URL that exists or null if none were found */ -export default async function filesExist(urls: string[]): Promise { - const promises = urls.map(async (url) => { - if (await fileExists(url)) { - return url; - } - return null; - }); +export default async function filesExist( + urls: string[], +): Promise { + const promises = urls.map(async (url) => { + if (await fileExists(url)) { + return url; + } + return null; + }); - // Run all in parallel - const results = await Promise.all(promises); + // Run all in parallel + const results = await Promise.all(promises); - // Find the first URL that exists (not null) or return null if none exist - for (const result of results) { - if (result !== null) { - return result; - } + // Find the first URL that exists (not null) or return null if none exist + for (const result of results) { + if (result !== null) { + return result; } + } - return null; // None of the URLs exist + return null; // None of the URLs exist } -- cgit