Micro Hyphenization Utility

0.2.0 · maintenance · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

view raw JSON →