@qntm-code/utils
Version:
A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.
22 lines (21 loc) • 693 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.capitalise = void 0;
/**
* Capitalises the characters of a provided string between the given start and end indexes
*/
function capitalise(value, options) {
const { length } = value;
let { start, end } = { start: 0, end: length, ...options };
if (start < 0) {
start = 0;
}
if (end > length) {
end = length;
}
const stringStart = value.substring(0, start);
const capitalise = value.substring(start, end);
const stringEnd = value.substring(end, length);
return `${stringStart}${capitalise.toUpperCase()}${stringEnd}`;
}
exports.capitalise = capitalise;