1.0.17 • Published 5 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
5 months ago
1.0.16
6 months ago
1.0.15
6 months ago
1.0.14
6 months ago
1.0.13
7 months ago
1.0.12
7 months ago
1.0.11
7 months ago
1.0.10
7 months ago
1.0.9
7 months ago
1.0.8
7 months ago
1.0.7
7 months ago
1.0.6
7 months ago
1.0.5
7 months ago
1.0.4
7 months ago
1.0.3
7 months ago
1.0.2
7 months ago
1.0.1
7 months ago
1.0.0
7 months ago