Skip to content

Commit

Permalink
fix: Optimiser les filtres.
Browse files Browse the repository at this point in the history
  • Loading branch information
regseb committed Aug 11, 2024
1 parent b9e5397 commit f1b9522
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/scraper/tools/filter/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const NUMBER_PATTERN = new RegExp(

const compile = (filter) => {
if (undefined === filter) {
return (_item) => true;
return undefined;
}
let result = STRING_PATTERN.exec(filter);
if (null !== result) {
Expand All @@ -74,7 +74,7 @@ const compile = (filter) => {

export default class FilterScraper {
/**
* La fonction pour filtrer prennant en argument un élément et retournant un
* La fonction pour filtrer prenant en argument un élément et retournant un
* booléen.
*
* @type {Function}
Expand All @@ -94,6 +94,9 @@ export default class FilterScraper {
}

async extract(max = Number.MAX_SAFE_INTEGER) {
if (undefined === this.#filter) {
return this.#scraper.extract(max);
}
const items = await this.#scraper.extract(Number.MAX_SAFE_INTEGER);
return items.filter(this.#filter).slice(0, max);
}
Expand Down

0 comments on commit f1b9522

Please sign in to comment.