Initial Commit
linter / quality (push) Canceled after 0s
tests / ci (8.3) (push) Canceled after 0s
tests / ci (8.4) (push) Canceled after 0s
tests / ci (8.5) (push) Canceled after 0s

This commit is contained in:
2026-08-28 21:50:26 +10:00
commit d8d4ecbe8a
142 changed files with 25234 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
export type UseInitialsReturn = {
getInitials: (fullName?: string) => string;
};
function getInitial(name: string): string {
return Array.from(name)[0] ?? '';
}
export function getInitials(fullName?: string): string {
if (!fullName) {
return '';
}
const names = fullName.trim().split(/\s+/u).filter(Boolean);
if (names.length === 0) {
return '';
}
if (names.length === 1) {
return getInitial(names[0]).toUpperCase();
}
return `${getInitial(names[0])}${getInitial(names[names.length - 1])}`.toUpperCase();
}
export function useInitials(): UseInitialsReturn {
return { getInitials };
}