mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 03:31:10 +00:00
17 lines
436 B
TypeScript
17 lines
436 B
TypeScript
export function uniqueStrings(
|
|
values: readonly string[] | undefined,
|
|
normalize: (value: string) => string = (value) => value,
|
|
): string[] {
|
|
const result: string[] = [];
|
|
const seen = new Set<string>();
|
|
for (const value of values ?? []) {
|
|
const normalized = normalize(value);
|
|
if (!normalized || seen.has(normalized)) {
|
|
continue;
|
|
}
|
|
seen.add(normalized);
|
|
result.push(normalized);
|
|
}
|
|
return result;
|
|
}
|