Removed duplicate code in getAllSources

This commit is contained in:
Jonathan Barrow
2023-09-26 13:24:16 -04:00
parent 6ca9de8d74
commit 6f29b636ea

View File

@@ -43,30 +43,15 @@ const sources = getAllSources();
function getAllSources() { function getAllSources() {
// * The only way to get a list of all sources is to // * The only way to get a list of all sources is to
// * create all these things. Maybe this should change // * create all these things. Maybe this should change
const nativeSources = makeProviders({ const providers = makeProviders({
fetcher: makeStandardFetcher(nodeFetch), fetcher: makeStandardFetcher(nodeFetch),
target: targets.NATIVE target: targets.NATIVE
}).listSources(); })
const browserSources = makeProviders({ const sources = providers.listSources();
fetcher: makeStandardFetcher(nodeFetch), const embeds = providers.listEmbeds();
target: targets.BROWSER
}).listSources();
const nativeEmbeds = makeProviders({ const combined = [...sources, ...embeds];
fetcher: makeStandardFetcher(nodeFetch),
target: targets.NATIVE
}).listEmbeds();
const browserEmbeds = makeProviders({
fetcher: makeStandardFetcher(nodeFetch),
target: targets.BROWSER
}).listEmbeds();
const combined = [
...nativeSources, ...browserSources,
...nativeEmbeds, ...browserEmbeds
];
// * Remove dupes // * Remove dupes
const map = new Map(combined.map(source => [source.id, source])); const map = new Map(combined.map(source => [source.id, source]));