UNPKG

@zohodesk/components

Version:

In this Package, we Provide Some Basic Components to Build Web App

33 lines (26 loc) 840 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getInitial = getInitial; exports.getInitialByPattern = getInitialByPattern; function getInitial() { var firstName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var lastName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; var initial = ''; if (firstName) { firstName = firstName.trim(); initial = firstName[0]; } if (lastName) { lastName = lastName.trim(); initial += initial ? lastName[0] : lastName.substring(0, 2); } return initial ? initial.toUpperCase() : initial; } function getInitialByPattern(firstName, lastName, pattern) { if (pattern[0] === 'FIRST_NAME') { return getInitial(firstName, lastName); } return getInitial(lastName, firstName); }