This commit is contained in:
2026-06-30 15:53:01 +07:00
parent 595aebd8a5
commit 74b540cac2
19 changed files with 1719 additions and 252 deletions

View File

@@ -0,0 +1,21 @@
export function parseKeywordSet(csv: string): Set<string> {
return new Set(
csv
.split(',')
.map((s) => s.trim().toLowerCase())
.filter(Boolean),
);
}
export function mergeKeywordCSV(current: string, addition: string): string {
const set = parseKeywordSet(current);
addition.split(',').forEach((k) => {
const kw = k.trim().toLowerCase();
if (kw) set.add(kw);
});
return Array.from(set).join(', ');
}
export function countKeywords(csv: string): number {
return parseKeywordSet(csv).size;
}