UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

26 lines (25 loc) 867 B
/** * Capitalize the first letter of the input _only if_ the given options specifies doing so. * * @category String * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export function maybeCapitalize(input, casingOptions) { return casingOptions.capitalizeFirstLetter ? capitalizeFirstLetter(input) : input; } /** * Capitalize the first letter of the input. * * @category String * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export function capitalizeFirstLetter(input) { if (!input.length) { return ''; } // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const firstLetter = input[0]; return (firstLetter.toUpperCase() + input.slice(1)); }