Registry / serialization / case
library1.5.3jsnpmunverified

The `case` package (npm: `case`, version 1.6.3) provides an extensible utility for converting, identifying, and flipping string cases. It supports various common formats like camelCase, PascalCase, snake_case, kebab-case, and CONSTANT_CASE, as well as UI-focused cases like Title Case and Sentence case. A key differentiator is its extensibility, allowing users to define custom case types. Additionally, its `sentence` function offers specialized handling for proper names and abbreviations. This package was last updated over six years ago, with version 1.6.3 published six years ago, indicating it is no longer actively maintained. Its release cadence was sporadic, with significant gaps between updates in its later history. It ships with TypeScript types, supporting usage in modern TypeScript projects, but its primary target environment was Node.js >= 0.8.0 and browsers via UMD, reflecting an older development era.

npm install case
INSTALL
IMPORT
SIG · CASE
C
case
serializationjavascriptv1.5.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Case
import Case from 'case';
import { Case } from 'case';
The library exports a default object named 'Case' containing all utility methods. Do not use named import destructuring.
Case (CommonJS)
const Case = require('case');
This package primarily targets CommonJS environments, so `require` is the intended usage. However, for modern Node.js ESM projects, `import Case from 'case';` is preferred.
Case.snake, Case.camel, etc.
import Case from 'case'; Case.snake('Foo bar!');
import { snake } from 'case';
All case conversion methods are properties of the default 'Case' object. They are not individually named exports.

This quickstart demonstrates common string case conversions, UI helpers, and the case identification utility, showcasing the library's core functionality with modern ESM imports.

import Case from 'case'; // Basic case conversions console.log(Case.upper('hello_world')); // Expected: 'HELLO WORLD' console.log(Case.lower('Hello_World')); // Expected: 'hello world' console.log(Case.camel('hello world')); // Expected: 'helloWorld' console.log(Case.snake('Hello World')); // Expected: 'hello_world' console.log(Case.pascal('hello-world')); // Expected: 'HelloWorld' // UI-focused helpers console.log(Case.title('the quick brown fox')); // Expected: 'The Quick Brown Fox' // Sentence case with proper name and abbreviation handling const text = 'dr. smith went to the u.s.a.'; const names = ['Smith', 'U.S.A.']; const abbreviations = ['dr']; console.log(Case.sentence(text, names, abbreviations)); // Expected: 'Dr. Smith went to the U.S.A.' // Custom casing (fill non-alphanumeric with a specified character) console.log(Case.upper('foo-bar', '_')); // Expected: 'FOO_BAR' // Identify string case console.log(Case.of('fooBar')); // Expected: 'camel' console.log(Case.of('foo_bar')); // Expected: 'snake'
Debug
Known issues
breakingThe `squish` method was deprecated in version 1.2.0. While it might still exist for backward compatibility, `pascal` should be used instead for similar functionality.
fix
Replace `Case.squish(str)` with `Case.pascal(str)`.
affects: >=1.2.0
gotchaThe npm package name is `case` (lowercase), but the utility object exported by the library is `Case` (uppercase). Directly importing `Case` is necessary, not destructuring named exports like `{ case }` or `{ Case }`.
fix
Use `import Case from 'case';` for ESM or `const Case = require('case');` for CommonJS.
affects: >=1.0.0
breakingThis package is effectively abandoned. The last publish was six years ago, meaning there will be no new features, bug fixes, or security updates. Relying on this package for new projects is not recommended due to potential unaddressed vulnerabilities or compatibility issues with newer JavaScript runtimes.
fix
Consider migrating to a actively maintained string utility library that provides similar functionality and receives regular updates. If continued use is necessary, thoroughly audit the codebase for security concerns.
affects: >=1.6.3
gotchaDue to its age and original design for Node.js 0.8.0, the package primarily functions as a CommonJS module. While bundlers and Node.js can often handle mixed modules, direct ESM `import` statements might have unexpected behavior or require specific build configurations for optimal compatibility in some environments.
fix
For CommonJS projects, use `const Case = require('case');`. For ESM projects, `import Case from 'case';` should work, but be mindful of potential tooling configuration for older modules. Test thoroughly in your target environment.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Case.camel is not a function
The 'Case' object was not imported correctly, or the module was treated as a named export instead of a default export.
fix
Ensure you are using `import Case from 'case';` in ESM or `const Case = require('case');` in CommonJS. The library exports its API as properties of a single default object, not as individual named exports.
ReferenceError: Case is not defined
The `case` package was not imported or required at all, or it was imported into a scope where the `Case` variable is not accessible.
fix
Add `import Case from 'case';` at the top of your ESM file or `const Case = require('case');` in your CommonJS file. Ensure it's in the correct scope for where you intend to use it.
ERR_REQUIRE_ESM: require() of ES Module ... not supported
Attempting to `require()` an ESM-only package in a CommonJS context, or `case` itself is being treated as ESM when your project expects CJS, despite its age. While `case` itself is CJS-first, this error can arise in complex mixed-module environments or if `package.json` configurations are misaligned.
fix
Verify your project's module type. If `case` is mistakenly treated as ESM by a bundler, adjust the bundler configuration. For newer projects, try using `import Case from 'case';` instead of `require('case')` in an ESM context.
Upgrade
Version history
1.5.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources