import { Pipe, PipeTransform } from '@angular/core'; // enums import { eStringPlaceholder } from '../enums'; @Pipe({ name: 'nameInitials', standalone: true, }) export class NameInitialsPipe implements PipeTransform { constructor() {} transform(fullName: string | number | undefined): string { const fullname = fullName?.toString(); if (!fullname) return eStringPlaceholder.EMPTY; const initials: string = fullname .split(eStringPlaceholder.WHITESPACE) .map((x) => x.charAt(0)) .join(eStringPlaceholder.EMPTY) .substr(0, 2) .toUpperCase(); return initials; } }