Array of Kenmei manga entries.
Filter options including status, minimum chapters, and score presence.
Filtered manga entries matching all specified criteria.
export function filterMangaEntries(
entries: KenmeiManga[],
criteria: {
status?: KenmeiStatus[];
minChapters?: number;
hasProgress?: boolean;
hasScore?: boolean;
},
): KenmeiManga[] {
return entries.filter((entry) => {
if (criteria.status?.length) {
if (!criteria.status.includes(entry.status)) return false;
}
if (criteria.minChapters !== undefined) {
if ((entry.chaptersRead ?? 0) < criteria.minChapters) return false;
}
if (criteria.hasProgress) {
const chapters = entry.chaptersRead ?? 0;
const volumes = entry.volumesRead ?? 0;
if (chapters <= 0 && volumes <= 0) return false;
}
if (criteria.hasScore) {
if ((entry.score ?? 0) <= 0) return false;
}
return true;
});
}
Filter manga entries by status, progress, and score criteria.