1.0.17 • Published 7 months ago

@uvarovag/to-camel-case v1.0.17

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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

7 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago