clean ui
This commit is contained in:
21
management/src/utils/appKeywords.ts
Normal file
21
management/src/utils/appKeywords.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user