Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Waiting for all requests to finish before closing q. #690

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/api/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async function _export({
let match;
let pattern = /<a ([\s\S]+?)>/gm;

let promise;
const urls = [];

while (match = pattern.exec(cleaned)) {
const attrs = match[1];
Expand All @@ -183,12 +183,14 @@ async function _export({
const url = resolve(base.href, href);

if (url.protocol === protocol && url.host === host) {
promise = handle(url);
urls.push(url);
}
}
}

await promise;
for (let i = 0; i < urls.length; i += concurrent) {
await Promise.all(urls.slice(i, i + concurrent).map(handle));
}
}
}
}
Expand Down