Registry / serialization / uhyphen

uhyphen

JSON →
library0.2.0jsnpmunverified

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.

npm install uhyphen
INSTALL
IMPORT
SIG · UHYPHEN
U
uhyphen
serializationjavascriptv0.2.0
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.

uhyphen
import uhyphen from 'uhyphen';
import { uhyphen } from 'uhyphen';
The 'uhyphen' library provides a default export. Destructured imports like '{ uhyphen }' will result in 'undefined' because there is no named export for 'uhyphen'.
uhyphen (CJS)
const uhyphen = require('uhyphen');
import uhyphen from 'uhyphen';
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.
uhyphen (Type)
import uhyphen from 'uhyphen'; // Usage with JSDoc
import type { uhyphen } from 'uhyphen';
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.

Demonstrates how to import and use the 'uhyphen' function to convert various camelCase strings into their corresponding kebab-case (hyphenated) forms.

import uhyphen from 'uhyphen'; // Example 1: Basic camelCase to kebab-case transformation const camelCaseString1 = 'XMLHttpRequest'; const kebabCaseString1 = uhyphen(camelCaseString1); console.log(`'${camelCaseString1}' -> '${kebabCaseString1}'`); // Expected: 'XMLHttpRequest' -> 'xml-http-request' // Example 2: Another common camelCase pattern const camelCaseString2 = 'myAwesomeComponent'; const kebabCaseString2 = uhyphen(camelCaseString2); console.log(`'${camelCaseString2}' -> '${kebabCaseString2}'`); // Expected: 'myAwesomeComponent' -> 'my-awesome-component' // Example 3: Handling leading capitals const camelCaseString3 = 'HTMLElement'; const kebabCaseString3 = uhyphen(camelCaseString3); console.log(`'${camelCaseString3}' -> '${kebabCaseString3}'`); // Expected: 'HTMLElement' -> 'html-element' // The utility is synchronous and returns the transformed string.
Debug
Known issues
gotchaThe '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.
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.
affects: >=0.1.0
gotchaAs 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.
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.
affects: >=0.1.0
gotchaThis 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.
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.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: uhyphen is not a function
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.
fix
Change your import statement from `import { uhyphen } from 'uhyphen'` to `import uhyphen from 'uhyphen'` to correctly import the default export.
Cannot find module 'uhyphen' or its corresponding type declarations.
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.
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.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
uhyphen — npm install uhyphen · libregistry