Skip to content

Commit 24408b5

Browse files
committed
Process entries sequentially, respectinng --wait value
1 parent d80cac0 commit 24408b5

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

index.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,23 @@ async function cleanup(url, options) {
223223
If the file is a valid RSS/Atom feed
224224
extract the feed entries to be processed further.
225225
*/
226+
226227
if (isFeed(doc)) {
227-
return await Promise.all(
228-
processFeed(doc).map(async it => {
229-
const itemDOM = new JSDOM(wrapHTMLFragment(it), {
230-
url: it.url
228+
const w = options.wait * 1000;
229+
const entries = processFeed(doc);
230+
return resolveSequence(
231+
entries,
232+
async entry => {
233+
const itemDOM = new JSDOM(wrapHTMLFragment(entry), {
234+
url: entry.url
231235
});
232-
it.content = itemDOM.window.document.body;
233-
const clean = await cleanupItem(itemDOM, options, it, ENV);
236+
entry.content = itemDOM.window.document.body;
237+
const clean = await cleanupItem(
238+
itemDOM,
239+
options,
240+
entry,
241+
ENV
242+
);
234243
return {
235244
...clean,
236245
// TODO
@@ -239,7 +248,8 @@ async function cleanup(url, options) {
239248
contentType: 'text/html'
240249
}
241250
};
242-
})
251+
},
252+
Number.isFinite(w) && w >= 0 ? w : 0
243253
);
244254
}
245255

0 commit comments

Comments
 (0)