mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 04:47:03 -06:00
refactor: share human list formatting
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
export function formatHumanList(values: readonly string[]): string {
|
||||
if (values.length === 0) {
|
||||
return "";
|
||||
}
|
||||
if (values.length === 1) {
|
||||
return values[0];
|
||||
}
|
||||
if (values.length === 2) {
|
||||
return `${values[0]} or ${values[1]}`;
|
||||
}
|
||||
return `${values.slice(0, -1).join(", ")}, or ${values.at(-1)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user