mirror of
https://github.com/p-stream/providers.git
synced 2026-03-11 17:55:36 +00:00
Removed duplicate code in getAllSources
This commit is contained in:
parent
6ca9de8d74
commit
6f29b636ea
1 changed files with 5 additions and 20 deletions
|
|
@ -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]));
|
||||
|
|
|
|||
Loading…
Reference in a new issue