{"id":12945,"library":"case","title":"Case String Utilities","description":"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.","status":"abandoned","version":"1.6.3","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/nbubna/Case","tags":["javascript","string","case","camel","title","upper","lower","snake","squish","typescript"],"install":[{"cmd":"npm install case","lang":"bash","label":"npm"},{"cmd":"yarn add case","lang":"bash","label":"yarn"},{"cmd":"pnpm add case","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library exports a default object named 'Case' containing all utility methods. Do not use named import destructuring.","wrong":"import { Case } from 'case';","symbol":"Case","correct":"import Case from 'case';"},{"note":"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.","symbol":"Case (CommonJS)","correct":"const Case = require('case');"},{"note":"All case conversion methods are properties of the default 'Case' object. They are not individually named exports.","wrong":"import { snake } from 'case';","symbol":"Case.snake, Case.camel, etc.","correct":"import Case from 'case';\nCase.snake('Foo bar!');"}],"quickstart":{"code":"import Case from 'case';\n\n// Basic case conversions\nconsole.log(Case.upper('hello_world')); // Expected: 'HELLO WORLD'\nconsole.log(Case.lower('Hello_World')); // Expected: 'hello world'\nconsole.log(Case.camel('hello world')); // Expected: 'helloWorld'\nconsole.log(Case.snake('Hello World')); // Expected: 'hello_world'\nconsole.log(Case.pascal('hello-world')); // Expected: 'HelloWorld'\n\n// UI-focused helpers\nconsole.log(Case.title('the quick brown fox')); // Expected: 'The Quick Brown Fox'\n\n// Sentence case with proper name and abbreviation handling\nconst text = 'dr. smith went to the u.s.a.';\nconst names = ['Smith', 'U.S.A.'];\nconst abbreviations = ['dr'];\nconsole.log(Case.sentence(text, names, abbreviations)); // Expected: 'Dr. Smith went to the U.S.A.'\n\n// Custom casing (fill non-alphanumeric with a specified character)\nconsole.log(Case.upper('foo-bar', '_')); // Expected: 'FOO_BAR'\n\n// Identify string case\nconsole.log(Case.of('fooBar')); // Expected: 'camel'\nconsole.log(Case.of('foo_bar')); // Expected: 'snake'\n","lang":"typescript","description":"This quickstart demonstrates common string case conversions, UI helpers, and the case identification utility, showcasing the library's core functionality with modern ESM imports."},"warnings":[{"fix":"Replace `Case.squish(str)` with `Case.pascal(str)`.","message":"The `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.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Use `import Case from 'case';` for ESM or `const Case = require('case');` for CommonJS.","message":"The 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 }`.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"This 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.","severity":"breaking","affected_versions":">=1.6.3"},{"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.","message":"Due 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"The 'Case' object was not imported correctly, or the module was treated as a named export instead of a default export.","error":"TypeError: Case.camel is not a function"},{"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.","cause":"The `case` package was not imported or required at all, or it was imported into a scope where the `Case` variable is not accessible.","error":"ReferenceError: Case is not defined"},{"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.","cause":"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.","error":"ERR_REQUIRE_ESM: require() of ES Module ... not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}