@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.
29 lines • 934 B
JavaScript
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
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