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

2.1.0 • Public • Published

to-camel-case

Bundle Size tests

Lightweight utility function to convert strings into camelCase format. Supports both Latin and Cyrillic characters and works seamlessly with various delimiters such as spaces, underscores, hyphens, and more.

Installation

npm install @uvarovag/to-camel-case

Usage

ES Modules (ESM)

import { toCamelCase } from '@uvarovag/to-camel-case'

const result = toCamelCase('hello-world-test')
console.log(result) // Outputs: 'helloWorldTest'

CommonJS (CJS)

const { toCamelCase } = require('@uvarovag/to-camel-case')

const result = toCamelCase('hello-world-test')
console.log(result) // Outputs: 'helloWorldTest'

Examples

// Basic usage
console.log(toCamelCase('hello_world')) // Outputs: 'helloWorld'
console.log(toCamelCase('hello-world-test')) // Outputs: 'helloWorldTest'
console.log(toCamelCase('HELLO WORLD')) // Outputs: 'helloWorld'

// Supports Cyrillic
console.log(toCamelCase('привет мир')) // Outputs: 'приветМир'
console.log(toCamelCase('привет-мир_тест')) // Outputs: 'приветМирТест'

// Handles mixed characters
console.log(toCamelCase('hello мир test_case')) // Outputs: 'helloМирTestCase'

// Removes non-alphanumeric characters
console.log(toCamelCase('hello@world#test!')) // Outputs: 'helloWorldTest'

// Edge cases
console.log(toCamelCase('')) // Outputs: ''
console.log(toCamelCase('---___')) // Outputs: ''
console.log(toCamelCase('123_456-789')) // Outputs: '123456789'

Package Sidebar

Install

npm i @uvarovag/to-camel-case

Weekly Downloads

0

Version

2.1.0

License

MIT

Unpacked Size

4.04 kB

Total Files

5

Last publish

Collaborators

  • uvarovag