{"id":12268,"library":"uhyphen","title":"Micro Hyphenization Utility","description":"uhyphen is a compact, single-purpose JavaScript utility designed specifically for transforming camelCase strings into kebab-case (hyphenated strings). Currently at version 0.2.0, the package prioritizes a small footprint and focused functionality over extensive features. Its release cadence is infrequent, as the project appears to be stable and feature-complete for its intended use case, with the last code changes occurring several years ago. Key differentiators include its 'micro' nature, making it ideal for environments where bundle size and minimal dependencies are crucial. It provides a straightforward API for a common string manipulation task without incorporating complex linguistic hyphenation rules or broader string utility features.","status":"maintenance","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/WebReflection/uhyphen","tags":["javascript","camel","snake","hyphen","cases","transformer"],"install":[{"cmd":"npm install uhyphen","lang":"bash","label":"npm"},{"cmd":"yarn add uhyphen","lang":"bash","label":"yarn"},{"cmd":"pnpm add uhyphen","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The 'uhyphen' library provides a default export. Destructured imports like '{ uhyphen }' will result in 'undefined' because there is no named export for 'uhyphen'.","wrong":"import { uhyphen } from 'uhyphen';","symbol":"uhyphen","correct":"import uhyphen from 'uhyphen';"},{"note":"For CommonJS environments (e.g., older Node.js projects), 'require' is the correct syntax for importing a default export. Using ESM 'import' syntax directly in a CJS file will lead to syntax errors unless transpiled.","wrong":"import uhyphen from 'uhyphen';","symbol":"uhyphen (CJS)","correct":"const uhyphen = require('uhyphen');"},{"note":"The 'uhyphen' package does not ship with its own TypeScript declaration files (`.d.ts`). For type safety in TypeScript projects, you will need to either write an ambient module declaration (e.g., `declare module 'uhyphen';`) or rely on JSDoc comments for type inference.","wrong":"import type { uhyphen } from 'uhyphen';","symbol":"uhyphen (Type)","correct":"import uhyphen from 'uhyphen'; // Usage with JSDoc"}],"quickstart":{"code":"import uhyphen from 'uhyphen';\n\n// Example 1: Basic camelCase to kebab-case transformation\nconst camelCaseString1 = 'XMLHttpRequest';\nconst kebabCaseString1 = uhyphen(camelCaseString1);\nconsole.log(`'${camelCaseString1}' -> '${kebabCaseString1}'`);\n// Expected: 'XMLHttpRequest' -> 'xml-http-request'\n\n// Example 2: Another common camelCase pattern\nconst camelCaseString2 = 'myAwesomeComponent';\nconst kebabCaseString2 = uhyphen(camelCaseString2);\nconsole.log(`'${camelCaseString2}' -> '${kebabCaseString2}'`);\n// Expected: 'myAwesomeComponent' -> 'my-awesome-component'\n\n// Example 3: Handling leading capitals\nconst camelCaseString3 = 'HTMLElement';\nconst kebabCaseString3 = uhyphen(camelCaseString3);\nconsole.log(`'${camelCaseString3}' -> '${kebabCaseString3}'`);\n// Expected: 'HTMLElement' -> 'html-element'\n\n// The utility is synchronous and returns the transformed string.","lang":"javascript","description":"Demonstrates how to import and use the 'uhyphen' function to convert various camelCase strings into their corresponding kebab-case (hyphenated) forms."},"warnings":[{"fix":"Create a 'uhyphen.d.ts' file in your project's root or a types directory with `declare module 'uhyphen';` to resolve basic import errors. For specific type signatures, define them manually.","message":"The 'uhyphen' library does not ship with its own TypeScript declaration files. Users working in TypeScript projects will need to provide their own ambient module declarations or use JSDoc for type inference to avoid 'Cannot find module' errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"It is recommended to pin to exact versions in your 'package.json' (e.g., `\"uhyphen\": \"0.2.0\"`) and thoroughly test any updates before deploying to production environments, especially when dealing with pre-1.0 versions.","message":"As a 'micro utility' in version 0.x.y, the API is not subject to strict semantic versioning. While the library is stable for its current functionality, minor versions (e.g., 0.2.0 to 0.3.0) could potentially introduce breaking changes without a major version bump, though this is unlikely given the project's current status.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure input strings strictly adhere to a camelCase convention. For more diverse string transformations or complex hyphenation logic (like natural language hyphenation), consider using a more comprehensive string utility library.","message":"This utility specifically converts camelCase to kebab-case. It does not handle other string transformation patterns (e.g., snake_case, PascalCase with complex rules, or sentences with spaces/special characters) and may produce unexpected or incorrect results if input strings deviate significantly from standard camelCase format.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change your import statement from `import { uhyphen } from 'uhyphen'` to `import uhyphen from 'uhyphen'` to correctly import the default export.","cause":"This error typically occurs when attempting to use 'uhyphen' as a named export (e.g., `import { uhyphen } from 'uhyphen'`) when it is exclusively a default export.","error":"TypeError: uhyphen is not a function"},{"fix":"Create a file named `uhyphen.d.ts` in your project (e.g., in a `src/types` or `types` directory) and add the content `declare module 'uhyphen';` to provide a minimal type declaration, or a more detailed one if specific function signatures are needed.","cause":"This is a common TypeScript error indicating that the TypeScript compiler cannot locate the module or its type definitions. 'uhyphen' does not ship with `.d.ts` files.","error":"Cannot find module 'uhyphen' or its corresponding type declarations."}],"ecosystem":"npm"}