Use Promise.all to fetch files part of py-config (#1322)

This is a first step towards loading more stuff simultaneously rather
than sequentially.

The functional part of this is pretty small: call `calculateFetchPaths` and
then `Promise.all(fetchPaths.map(loadFileFromURL));`. I also transposed the
return type of `calculateFetchPaths` since it's more convenient to consume
this way.

I redid the logic in `calculateFetchPaths` a bit. I renamed `src/plugins/fetch.ts`
to `calculateFetchPaths.ts` since the file performs no fetching. I also
renamed `loadFromFile` to `loadFileFromURL`.
This commit is contained in:
Hood Chatham
2023-03-29 07:32:09 -07:00
committed by GitHub
parent 26f07246e1
commit 9fedfe3699
6 changed files with 80 additions and 85 deletions

View File

@@ -80,7 +80,7 @@ export function joinPaths(parts: string[], separator = '/') {
.map(function (part) {
return part.trim().replace(/(^[/]*|[/]*$)/g, '');
})
.filter(p => p !== '')
.filter(p => p !== '' && p !== '.')
.join(separator || '/');
if (parts[0].startsWith('/')) {
return '/' + res;