Skip to content

A versatile JavaScript library for converting strings between camel case, Pascal case, snake case, underscore and other.

License

Notifications You must be signed in to change notification settings

jsheaven/case-converter

Repository files navigation

@jsheaven/case-converter

This package provides utility functions for converting strings between various text casing formats in JavaScript/TypeScript. It supports conversion between camelCase, PascalCase, snake_case, and kebab-case. The package can be used to standardize the casing of strings, particularly when dealing with APIs, file names, or data serialization.

User Stories

  1. As a developer, I want to convert strings from one casing format to another.
  2. As a developer, I want to ensure consistency in the casing of strings within my application.
  3. As a developer, I want to have a library that is easy to use and integrates well with my existing codebase.

Features

  • ✅ Supports conversion between camelCase, PascalCase, snake_case, and kebab-case.
  • ✅ Provides functions for both converting strings from one format to another and vice versa.
  • ✅ Lightweight and easy to integrate into existing projects.
  • ✅ Provides TypeScript support with type definitions.
  • ✅ Just 600 byte nano sized (ESM, gizpped)
  • ✅ Tree-shakable and side-effect free
  • ✅ Runs on Windows, Mac, Linux, CI tested
  • ✅ First class TypeScript support
  • ✅ 100% Unit Test coverage

Example Usage

Setup

  • yarn: yarn add @jsheaven/case-converter
  • npm: npm install @jsheaven/case-converter

Usage in JavaScript/TypeScript

import { convert } from '@jsheaven/case-converter'

const inputString = 'hello_world'
const convertedString = convert('SnakeCase', 'CamelCase', inputString)

console.log(convertedString) // Output: helloWorld

CommonJS

const { convert } = require('@jsheaven/case-converter')

const inputString = 'hello_world'
const convertedString = convert('SnakeCase', 'CamelCase', inputString)

console.log(convertedString) // Output: helloWorld

About

A versatile JavaScript library for converting strings between camel case, Pascal case, snake case, underscore and other.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published