@zerodep/case-camel
TypeScript icon, indicating that this package has built-in type declarations

2.0.9 • Public • Published

@zerodep/case-camel

version language types license

CodeFactor Known Vulnerabilities

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.

Examples

All @zerodep packages support both ESM and CJS.

import { caseCamel } from '@zerodep/case-camel';
// or
const { caseCamel } = require('@zerodep/case-camel');

Use Cases

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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @zerodep/case-camel

      Homepage

      zerodep.app

      Weekly Downloads

      0

      Version

      2.0.9

      License

      MIT

      Unpacked Size

      11.5 kB

      Total Files

      7

      Last publish

      Collaborators

      • cdepage