@azizbecha/strkit
Version:
strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.
19 lines • 515 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = toCamelCase;
/**
* Converts a string to camelCase.
*
* @param str - The string to convert
* @returns The camelCase string
*
* @example
* toCamelCase('hello world'); // "helloWorld"
* toCamelCase('This-is-a-test'); // "thisIsATest"
*/
function toCamelCase(str) {
return str
.toLowerCase()
.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : '');
}
//# sourceMappingURL=toCamelCase.js.map