mirror of
https://github.com/langgenius/dify.git
synced 2026-11-11 22:02:23 +08:00
8 lines
295 B
TypeScript
8 lines
295 B
TypeScript
const avatarInitialSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' })
|
|
|
|
export function getAvatarInitial(name: string | null | undefined): string {
|
|
for (const { segment } of avatarInitialSegmenter.segment(name?.trim() ?? ''))
|
|
return segment.toUpperCase()
|
|
return '?'
|
|
}
|