@augment-vir/common
Version:
A collection of augments, helpers types, functions, and classes for any JavaScript environment.
30 lines (29 loc) • 1.05 kB
JavaScript
/* node:coverage disable */
/**
* Capitalize the first letter of the input _only if_ the given options specifies doing so.
*
* @deprecated Prefer `setFirstLetterCasing`.
* @category String
* @category Package : @augment-vir/common
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
*/
export function maybeCapitalize(input, casingOptions) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return casingOptions.capitalizeFirstLetter ? capitalizeFirstLetter(input) : input;
}
/**
* Capitalize the first letter of the input.
*
* @deprecated Prefer `setFirstLetterCasing`.
* @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));
}