From 6f29b636ead81d7252ac2eacbe61b3c120a91cdd Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Tue, 26 Sep 2023 13:24:16 -0400 Subject: [PATCH] Removed duplicate code in getAllSources --- run-source.ts | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/run-source.ts b/run-source.ts index 3f53106..0be2667 100644 --- a/run-source.ts +++ b/run-source.ts @@ -43,30 +43,15 @@ const sources = getAllSources(); function getAllSources() { // * The only way to get a list of all sources is to // * create all these things. Maybe this should change - const nativeSources = makeProviders({ + const providers = makeProviders({ fetcher: makeStandardFetcher(nodeFetch), target: targets.NATIVE - }).listSources(); + }) - const browserSources = makeProviders({ - fetcher: makeStandardFetcher(nodeFetch), - target: targets.BROWSER - }).listSources(); + const sources = providers.listSources(); + const embeds = providers.listEmbeds(); - const nativeEmbeds = makeProviders({ - fetcher: makeStandardFetcher(nodeFetch), - target: targets.NATIVE - }).listEmbeds(); - - const browserEmbeds = makeProviders({ - fetcher: makeStandardFetcher(nodeFetch), - target: targets.BROWSER - }).listEmbeds(); - - const combined = [ - ...nativeSources, ...browserSources, - ...nativeEmbeds, ...browserEmbeds - ]; + const combined = [...sources, ...embeds]; // * Remove dupes const map = new Map(combined.map(source => [source.id, source]));