MCPcopy Create free account
hub / github.com/cloudflare/realtimekit-ui / getInitials

Function getInitials

packages/core/src/utils/string.ts:50–60  ·  view source on GitHub ↗
(name: string, maxInitials = 2)

Source from the content-addressed store, hash-verified

48const space = new RegExp(/\s+/);
49
50export function getInitials(name: string, maxInitials = 2) {
51 // removes any character that is not a letter, number or whitespace
52 const cleanedName = name.replace(whiteSpace, '');
53
54 const words = cleanedName.trim().split(space).slice(0, maxInitials);
55
56 return words
57 .map((word) => word.charAt(0))
58 .join('')
59 .toUpperCase();
60}

Callers 3

RtkAvatarClass · 0.90
renderMethod · 0.90
string.spec.tsFile · 0.90

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected