UNPKG

@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.

16 lines 422 B
/** * 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" */ export default function toCamelCase(str) { return str .toLowerCase() .replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : ''); } //# sourceMappingURL=toCamelCase.js.map