aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/filesExist.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webAO/utils/filesExist.ts')
-rw-r--r--webAO/utils/filesExist.ts32
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
}