npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lindorm/case

v0.2.1

Published

String case conversion utilities for strings, object keys, and string arrays.

Readme

@lindorm/case

String case conversion utilities for strings, object keys, and string arrays.

Installation

npm install @lindorm/case

This package is ESM-only. Import it with import syntax from a project that supports ECMAScript modules.

Features

  • Convert strings between 11 case conventions: camel, capital, constant, dot, header, kebab, lower, pascal, path, sentence, snake.
  • Convert the keys of an object (or an array of objects) recursively, preserving values.
  • Convert an array of strings element-by-element; non-string entries pass through untouched.
  • Generic changeCase and changeKeys dispatchers that pick a conversion at runtime via a string mode.

Supported case modes

| Mode | Example output | | ---------- | --------------- | | camel | camelCase | | capital | Capital Case | | constant | CONSTANT_CASE | | dot | dot.case | | header | Header-Case | | kebab | kebab-case | | lower | lower case | | pascal | PascalCase | | path | path/case | | sentence | Sentence case | | snake | snake_case | | none | input unchanged |

The none mode is only accepted by changeCase and changeKeys; it is not exposed as a dedicated function.

Usage

Convert a string

import { camelCase, pascalCase, snakeCase } from "@lindorm/case";

const a = camelCase("Hello world"); // "helloWorld"
const b = pascalCase("hello-world"); // "HelloWorld"
const c = snakeCase("HelloWorld"); // "hello_world"

Convert object keys

xxxKeys walks the input recursively. Object keys are transformed; nested objects and arrays of objects are walked; non-object/non-array values are kept as-is.

import { camelKeys } from "@lindorm/case";

const input = {
  user_id: "123",
  first_name: "Alice",
  contact_info: {
    phone_number: "555-0100",
  },
};

const output = camelKeys(input);
// {
//   userId: "123",
//   firstName: "Alice",
//   contactInfo: { phoneNumber: "555-0100" },
// }

The same function accepts an array of objects:

import { snakeKeys } from "@lindorm/case";

const rows = snakeKeys([{ firstName: "Alice" }, { firstName: "Bob" }]);
// [{ first_name: "Alice" }, { first_name: "Bob" }]

Convert an array of strings

xxxArray transforms string entries; any non-string entry is appended to the result unchanged.

import { kebabArray } from "@lindorm/case";

const result = kebabArray(["firstName", "lastName"]);
// ["first-name", "last-name"]

Pick a case at runtime

import { changeCase, changeKeys, type ChangeCase } from "@lindorm/case";

const mode: ChangeCase = "pascal";

const str = changeCase("hello-world", mode); // "HelloWorld"
const obj = changeKeys({ "first-name": "Alice" }, mode); // { FirstName: "Alice" }

ChangeCase is a string union ("camel" | "capital" | "constant" | "dot" | "header" | "kebab" | "lower" | "pascal" | "path" | "sentence" | "snake" | "none"), not an enum. Pass the literal string. If mode is omitted it defaults to "none", which returns the input unchanged.

API

Per-case functions

For each mode in camel, capital, constant, dot, header, kebab, lower, pascal, path, sentence, snake, the package exports three functions:

| Function | Signature | Description | | ------------- | ----------------------------------------- | ---------------------------------------------------------------- | | <mode>Case | (input: string) => string | Convert a single string. Throws if input is not a string. | | <mode>Keys | <T extends KeysInput>(input: T) => T | Recursively convert keys of an object or array of objects. | | <mode>Array | (input: Array<string>) => Array<string> | Convert each string entry; non-string entries are kept in place. |

So for example: camelCase, camelKeys, camelArray; snakeCase, snakeKeys, snakeArray; and so on for all 11 modes.

Generic dispatchers

| Function | Signature | Description | | ------------ | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | changeCase | (input: string, mode?: ChangeCase) => string | Apply the named case to a string. Defaults to "none". Throws on an unknown mode. | | changeKeys | <T extends KeysInput>(input: T, mode?: ChangeCase) => T | Apply the named case to the keys of an object or array of objects. Defaults to "none". Throws on an unknown mode. |

Types

| Type | Definition | Description | | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | | ChangeCase | "camel" \| "capital" \| "constant" \| "dot" \| "header" \| "kebab" \| "lower" \| "pascal" \| "path" \| "sentence" \| "snake" \| "none" | Mode accepted by changeCase and changeKeys. | | CaseCallback | (input: string) => string | Signature shared by all per-mode xxxCase functions. | | KeysInput | Dict \| Array<Dict> (where Dict is Record<string, any>) | Input shape accepted by xxxKeys and changeKeys. |

Error handling

  • xxxCase(input) throws if input is not a string (e.g. null, undefined, a number).
  • xxxKeys(input) and changeKeys(input, mode) throw if input is neither an object nor an array.
  • xxxArray(input) throws if input is not an array. Non-string entries inside the array are passed through, not converted.
  • changeCase and changeKeys throw Error("Invalid transform case [ ... ]") if mode is not one of the supported values.

License

AGPL-3.0-or-later