Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Fix dataset.reduce

Ondra Urban081a097dcfc1
diff --git a/src/dataset.js b/src/dataset.js
index 898b380db..22e151567 100644
--- a/src/dataset.js
+++ b/src/dataset.js
@@ -542,6 +542,7 @@ export class DatasetLocal {
async reduce(iteratee, memo) {
await this.initializationPromise;
const indexes = this._getItemIndexes();
+ if (memo === undefined) memo = indexes.shift();
for (const idx of indexes) {
const item = await this._readAndParseFile(idx);
memo = await iteratee(memo, item, idx - 1);