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

Commit d3fc0c1

Browse files
committed
Rate limiting the concurrent export requests based on the concurrent option. Default is 8.
1 parent a164834 commit d3fc0c1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/api/export.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ async function _export({
173173
let match;
174174
let pattern = /<a ([\s\S]+?)>/gm;
175175

176-
const promises = [];
176+
const urls = [];
177177

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

185185
if (url.protocol === protocol && url.host === host) {
186-
promises.push(handle(url));
186+
urls.push(url);
187187
}
188188
}
189189
}
190190

191-
await Promise.all(promises);
191+
for (let i = 0; i < urls.length; i += concurrent) {
192+
await Promise.all(urls.slice(i, i + concurrent).map(handle));
193+
}
192194
}
193195
}
194196
}

0 commit comments

Comments
 (0)