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

@cotter45/keycase

v1.0.1

Published

A rust based transformer for arrays and objects in JS

Readme

@cotter45/keycase

Recursively transforms all keys in a JavaScript object (including nested objects and arrays) into one of four common casings: camelCase, snake_case, PascalCase, or kebab-case. Written as a native Node.js addon in Rust via napi-rs for high performance, with both synchronous and Promise-based async APIs.

Install

npm install @cotter45/keycase

or

yarn add @cotter45/keycase

Usage

import { transform, transformAsync } from "@cotter45/keycase";

// Sync

const obj = {
  first_name: "Alice",
  user_profile: { join_date: "2024-01-15" },
  "kebab-key": [{ deep_value: 42 }],
};

const camel = transform(obj, "camel");
/**
{
firstName: 'Alice',
userProfile: { joinDate: '2024-01-15' },
kebabKey: [{ deepValue: 42 }]
}
*/

// Async

(async () => {
  const snake = await transformAsync(obj, "snake");
  // {
  // first_name: 'Alice',
  // user_profile: { join_date: '2024-01-15' },
  // kebab_key: [{ deep_value: 42 }]
  // }
})();

API

transform(obj, casing)

  • Parameters
    • obj (object): Any nested object/array
    • casing (string): 'camel' | 'snake' | 'pascal' | 'kebab'
  • Returns: A new object with all keys converted

transformAsync(obj, casing)

  • Exactly the same parameters as transform
  • Returns a Promise<object>—runs off the main thread

Supported Cases

  • camelfirstName
  • snakefirst_name
  • pascalFirstName
  • kebabfirst-name

Given this input

const obj = {
  first_name: "Alice",
  lastName: "Smith",
  "kebab-key": 123,
};

Casing Output

camel { firstName: 'Alice', lastName: 'Smith', kebabKey: 123 }
snake { first_name: 'Alice', last_name: 'Smith', kebab_key: 123 }
pascal { FirstName: 'Alice', LastName: 'Smith', KebabKey: 123 }
kebab { 'first-name': 'Alice', 'last-name': 'Smith', 'kebab-key': 123 }

Examples from Tests

import test from "ava";
import { transform } from "@cotter45/keycase";

// 4) Mixed key styles and deep nesting
const obj4 = {
  "kebab-key": {
    PascalKey: [
      { snake_case: 10, "another-kebab": false },
      { deep_nested: { inner_key: [1, 2, 3] } },
    ],
  },
  MixedCaseKey: "hello",
};

test("camel case", (t) => {
  t.deepEqual(transform(obj4, "camel"), {
    kebabKey: {
      pascalKey: [
        { snakeCase: 10, anotherKebab: false },
        { deepNested: { innerKey: [1, 2, 3] } },
      ],
    },
    mixedCaseKey: "hello",
  });
});

Performance

  • Sync: Large (~4 MB) objects transform in ~160 – 200 ms on modern hardware.
  • Async: Offloads the same work to a worker thread; adds ~50 ms scheduling overhead but keeps Node’s event loop free.

Under the hood, key strings are cached globally to avoid repeated conversions, and large arrays/objects are processed in parallel where beneficial.

Contributing

  1. Fork the repo
  2. yarn install && yarn build
  3. Add tests to test/*/.mjs
  4. Submit a PR

License

MIT