UNPKG

@momentum-ui/react-collaboration

Version:

Cisco Momentum UI Framework for React Collaboration Applications

19 lines 657 B
import { TYPES } from './Avatar.constants'; /** * Utility function to convert names into initials * * @param title The name of the person/space this avatar is for * @returns string with initials */ export var getInitials = function (title, type) { if (!title.replace(/\s/g, '').length) return ''; var letters = []; var words = title.trim().split(/ +/); letters.push(String.fromCodePoint(words[0].codePointAt(0))); if (type !== TYPES.space && words.length > 1) { letters.push(String.fromCodePoint(words[words.length - 1].codePointAt(0))); } return letters.join(''); }; //# sourceMappingURL=Avatar.utils.js.map