Files
buzz/desktop/src/shared/lib/initials.ts

12 lines
286 B
TypeScript

/** Derive up to two uppercase initials from a display name. */
export function getInitials(name: string): string {
return name
.replace(/[^\p{L}\p{N}\s]/gu, " ")
.trim()
.split(/\s+/)
.map((part) => part[0] ?? "")
.join("")
.slice(0, 2)
.toUpperCase();
}