1.0.17 • Published 6 months ago
@uvarovag/to-camel-case v1.0.17
to-camel-case
A 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.
Features
- Converts strings to camelCase.
- Handles multiple word delimiters (e.g., spaces, underscores, hyphens).
- Supports Latin and Cyrillic alphabets.
- Strips non-alphanumeric characters.
- Lightweight and dependency-free.
Installation
npm install @uvarovag/to-camel-case
Usage
import toCamelCase from '@uvarovag/to-camel-case'
const result: string = 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'
1.0.17
6 months ago
1.0.16
7 months ago
1.0.15
7 months ago
1.0.14
7 months ago
1.0.13
8 months ago
1.0.12
8 months ago
1.0.11
8 months ago
1.0.10
8 months ago
1.0.9
8 months ago
1.0.8
8 months ago
1.0.7
8 months ago
1.0.6
8 months ago
1.0.5
8 months ago
1.0.4
8 months ago
1.0.3
8 months ago
1.0.2
8 months ago
1.0.1
8 months ago
1.0.0
8 months ago