Skip to main content

@luca/cases@1.0.0

A collection of functions for converting strings between different cases.

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
100%
Published
2 months ago
deno add @luca/cases
import * as mod from "@luca/cases";
npx jsr add @luca/cases
import * as mod from "@luca/cases";
yarn dlx jsr add @luca/cases
import * as mod from "@luca/cases";
pnpm dlx jsr add @luca/cases
import * as mod from "@luca/cases";
bunx jsr add @luca/cases
import * as mod from "@luca/cases";

A collection of functions for converting strings between different cases.

This module provides functions for converting strings between camel case, snake case, kebab case, title case, pascal case, and constant case. It also provides a function for splitting a string into pieces based on spaces, dashes, underscores, and camel case.

All functions can be used with either a single string or an array of strings. The single string will be split into pieces using the splitPieces function.

import * as cases from "@luca/cases";

cases.splitPieces("helloWorld") // ["hello", "world"]
cases.camelCase("hello world") // "helloWorld"
cases.snakeCase("helloWorld") // "hello_world"
cases.kebabCase("hello_world") // "hello-world"
cases.titleCase("hello-world") // "Hello World"
cases.pascalCase(["hello", "world"]) // "HelloWorld"
cases.constantCase("hello world") // "HELLO_WORLD"
Built and signed on
GitHub Actions
View transparency log