A utility to convert a string to camelCase that also strips out non-alphanumeric characters and any leading numeric characters.
Full documentation is available at the zerodep.app page.
All @zerodep packages support both ESM and CJS.
import { caseCamel } from '@zerodep/case-camel';
// or
const { caseCamel } = require('@zerodep/case-camel');
caseCamel('From sentence case'); // "fromSentenceCase"
caseCamel('from.dot.case'); // "fromDotCase"
caseCamel('from-kebab-case'); // "fromKebabCase"
caseCamel('from_snake_case'); // "fromSnakeCase"
caseCamel('FromPascalCase'); // "fromPascalCase"
caseCamel(''); // ""
// with non-alphanumeric characters
caseCamel('A string with some !@#$%^& characters'); // "aStringWithSomeCharacters"
caseCamel('A #22 character long string'); // "a22CharacterLongString"
caseCamel("I'm a sp3c!al $741ng"); // "iMASp3cAl741ng"
// with accented characters
caseCamel('àëîóüý Žøñç'); // "aeiouyZonc"
// with leading special characters and numbers
caseCamel('__with many --- spaces'); // "withManySpaces"
caseCamel('12 monkeys see 6 bananas'); // "monkeysSee6Bananas"
// non-string values
caseCamel({ not: 'a string' }); // throws ZeroDepError: Value is not a string