@nebulaai/combine-words
v0.1.2
Published
Combine multiple words into a clean, formatted string.
Readme
🧩 combine-words
Mix strings and numbers like a wizard. Any separator. Any combination. Pure magic.
String alchemy from the NebulaAI lab
⚡ Get Started (One command)
npm install @nebulaai/combine-words🔥 Watch it work miracles
import { combineWords } from "@nebulaai/combine-words";
// Build file names like a boss
combineWords(["user", 123, "profile"], "_"); // → "user_123_profile"
// Create CSS classes dynamically
combineWords(["btn", "primary", "lg"]); // → "btnprimarylg"
combineWords(["nav", "item", 2], "-"); // → "nav-item-2"
// Generate URLs that just work
const path = combineWords(["api", "v2", "users", userId], "/");
// → "api/v2/users/42"
// Database table naming
combineWords(["order", "item", "history"], "_"); // → "order_item_history"
// Mixed data types? No problem.
combineWords([2024, "Q", 1, "report"], "-"); // → "2024-Q-1-report"🚀 Why smart devs use this
- Type flexible: Strings, numbers, whatever - it handles it
- Separator freedom: Use any character or none at all
- Zero surprises: Predictable output every single time
- TypeScript ready: IntelliSense knows what you're doing
- Performance beast: Optimized for speed and memory
- No edge cases: Works with empty arrays, nullish values, everything
🛠️ API That Adapts
combineWords(parts: Array<string | number>, sep?: string): string| Parameter | Type | Default | What it does |
|-----------|------|---------|--------------|
| parts | Array<string \| number> | - | The pieces to combine |
| sep | string | "" | What goes between each piece |
Returns: A perfectly combined string that does exactly what you expect.
🎯 Perfect for
- Dynamic class names →
"btn-primary-lg"without the headache - File path generation → Build paths that actually work
- API endpoint construction → Clean URLs every time
- Database naming → Consistent table/column names
- Template strings → Dynamic content assembly
- Data serialization → Turn arrays into readable strings
💡 Before vs After
// Before: Verbose, fragile, forgettable
function buildClassName(base, modifier, size) {
return [base, modifier, size].filter(Boolean).join("-");
}
// After: Clean, confident, bulletproof
import { combineWords } from "@nebulaai/combine-words";
const className = combineWords(["btn", modifier, size], "-");🔥 Pro moves
// Empty separator for tight combinations
combineWords(["React", "Hook", "Form"]); // → "ReactHookForm"
// Space-separated for natural language
combineWords(["Hello", "world", 2024], " "); // → "Hello world 2024"
// Custom separators for any format
combineWords(["user", 42, "admin"], "::"); // → "user::42::admin"
// Works with mixed arrays
combineWords([...tags, timestamp, userLevel]); // → Dynamic goodness📄 License
MIT © Jorge Gonzalez / Temporal AI Technologies Inc.
Building tools that make complex simple
