Array of Kenmei manga entries.
Filter criteria.
Filtered entries.
export function filterMangaEntries(
entries: KenmeiManga[],
criteria: {
status?: KenmeiStatus[];
minChapters?: number;
hasProgress?: boolean;
hasScore?: boolean;
},
): KenmeiManga[] {
return entries.filter((entry) => {
// Filter by status
if (criteria.status && !criteria.status.includes(entry.status)) {
return false;
}
// Filter by minimum chapters
if (
criteria.minChapters !== undefined &&
entry.chapters_read < criteria.minChapters
) {
return false;
}
// Filter by having progress
if (
criteria.hasProgress &&
entry.chapters_read <= 0 &&
(!entry.volumes_read || entry.volumes_read <= 0)
) {
return false;
}
// Filter by having score
if (criteria.hasScore && (!entry.score || entry.score <= 0)) {
return false;
}
return true;
});
}
Filter manga entries based on criteria.