diff options
| author | stonedDiscord <stonedDiscord@users.noreply.github.com> | 2024-11-20 13:31:50 +0000 |
|---|---|---|
| committer | GitHub Action <actions@github.com> | 2024-11-20 13:31:50 +0000 |
| commit | 6684f3fce6e90fd0574d7bab63b629554ab03ef6 (patch) | |
| tree | b2a62247d17e23a77af57aea355ba621666817c2 /webAO/utils/filesExist.ts | |
| parent | 95a2d1361d84c61b454ebe506e6963b93f6d8dee (diff) | |
Prettified Code!
Diffstat (limited to 'webAO/utils/filesExist.ts')
| -rw-r--r-- | webAO/utils/filesExist.ts | 32 |
1 files changed, 17 insertions, 15 deletions
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<string | null> { - const promises = urls.map(async (url) => { - if (await fileExists(url)) { - return url; - } - return null; - }); +export default async function filesExist( + urls: string[], +): Promise<string | null> { + 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 } |
