UNPKG

@alihbuzaid/ember-ui

Version:

Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.

52 lines (47 loc) 1 kB
import { capitalize, decamelize } from '@ember/string'; import { humanize } from 'ember-cli-string-helpers/helpers/humanize'; import { typeOf } from '@ember/utils'; export default function smartHumanize(string) { if (typeOf(string) !== 'string') { return string; } const uppercase = [ 'api', 'vat', 'id', 'uuid', 'sku', 'ean', 'upc', 'erp', 'tms', 'wms', 'ltl', 'ftl', 'lcl', 'fcl', 'rfid', 'jot', 'roi', 'eta', 'pod', 'asn', 'oem', 'ddp', 'fob', 'gsm', 'etd', 'eta', 'ect', ]; return humanize([decamelize(string)]) .toLowerCase() .split(' ') .map((word) => { if (uppercase.includes(word)) { return word.toUpperCase(); } return capitalize(word); }) .join(' '); }