Skip to content

Commit fde47d7

Browse files
committed
komoji
1 parent 4b091f1 commit fde47d7

File tree

18 files changed

+2674
-5092
lines changed

18 files changed

+2674
-5092
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
fail-fast: false
4747
matrix:
4848
package:
49-
- casing
49+
- komoji
5050
- fetch-api-client
5151
- find-pkg
5252
- http-errors

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ npm install @interweb/http-errors
125125

126126
### Utilities
127127

128-
#### [`@interweb/casing`](./packages/casing)
129-
String casing utilities for converting between different naming conventions.
128+
#### [`komoji`](./packages/komoji)
129+
the tiny case transformer — effortlessly transform strings between naming conventions
130130

131131
```bash
132-
npm install @interweb/casing
132+
npm install komoji
133133
```
134134

135135
#### [`@interweb/find-pkg`](./packages/find-pkg)

packages/casing/CHANGELOG.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/casing/README.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/komoji/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
## [0.7.2](https://github.com/hyperweb-io/dev-utils/compare/[email protected]@0.7.2) (2025-11-23)
7+
8+
**Note:** Version bump only for package komoji
9+
10+
## [0.7.1](https://github.com/hyperweb-io/dev-utils/compare/[email protected]@0.7.1) (2025-11-23)
11+
12+
**Note:** Version bump only for package komoji
13+
14+
# [0.7.0](https://github.com/hyperweb-io/dev-utils/compare/[email protected]@0.7.0) (2025-11-23)
15+
16+
**Note:** Version bump only for package komoji

packages/komoji/README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# komoji ✨
2+
3+
<p align="center">
4+
<img src="https://raw.githubusercontent.com/hyperweb-io/dev-utils/refs/heads/main/docs/img/logo.svg" width="80">
5+
<br />
6+
<strong>the tiny case transformer</strong>
7+
<br />
8+
<br />
9+
Effortlessly transform strings between naming conventions
10+
<br />
11+
<br />
12+
<a href="https://github.com/hyperweb-io/dev-utils/actions/workflows/ci.yml">
13+
<img height="20" src="https://github.com/hyperweb-io/dev-utils/actions/workflows/ci.yml/badge.svg" />
14+
</a>
15+
<a href="https://github.com/hyperweb-io/dev-utils/blob/main/LICENSE">
16+
<img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
17+
</a>
18+
</p>
19+
20+
## Why komoji?
21+
22+
komoji is your friendly companion for working with naming conventions. It's tiny, focused, and does one thing exceptionally well: transforming strings between different cases with zero dependencies.
23+
24+
Perfect for:
25+
- 🔄 Converting API responses to JavaScript conventions
26+
- 🎨 Generating code from schemas and templates
27+
- 🛠️ Building developer tools and CLI utilities
28+
- 📦 Processing configuration files across formats
29+
30+
## Install
31+
32+
```sh
33+
npm install komoji
34+
```
35+
36+
## Usage
37+
38+
### Transform to PascalCase
39+
40+
```typescript
41+
import { toPascalCase } from 'komoji';
42+
43+
toPascalCase('hello-world'); // HelloWorld
44+
toPascalCase('user_name'); // UserName
45+
toPascalCase('api response'); // ApiResponse
46+
toPascalCase('my-component_v2'); // MyComponentV2
47+
```
48+
49+
### Transform to camelCase
50+
51+
```typescript
52+
import { toCamelCase } from 'komoji';
53+
54+
toCamelCase('hello-world'); // helloWorld
55+
toCamelCase('user_name'); // userName
56+
toCamelCase('api-response-data'); // apiResponseData
57+
58+
// Strip leading non-alphabetic characters
59+
toCamelCase('__private_field', true); // privateField
60+
toCamelCase('123-invalid', true); // invalid
61+
```
62+
63+
### Validate Identifiers
64+
65+
```typescript
66+
import { isValidIdentifier, isValidIdentifierCamelized } from 'komoji';
67+
68+
// Check if string is a valid JavaScript identifier
69+
isValidIdentifier('myVar'); // true
70+
isValidIdentifier('my-var'); // false
71+
isValidIdentifier('123abc'); // false
72+
isValidIdentifier('_private'); // true
73+
74+
// Check if string can be camelized into valid identifier
75+
isValidIdentifierCamelized('my-var'); // true (can become myVar)
76+
isValidIdentifierCamelized('valid_id'); // true
77+
isValidIdentifierCamelized('-invalid'); // false (starts with hyphen)
78+
```
79+
80+
## API
81+
82+
### `toPascalCase(str: string): string`
83+
84+
Converts a string to PascalCase by capitalizing the first letter of each word and removing separators.
85+
86+
**Supported separators:** hyphens (`-`), underscores (`_`), spaces (` `)
87+
88+
### `toCamelCase(key: string, stripLeadingNonAlphabetChars?: boolean): string`
89+
90+
Converts a string to camelCase with an optional flag to strip leading non-alphabetic characters.
91+
92+
**Parameters:**
93+
- `key` - The string to transform
94+
- `stripLeadingNonAlphabetChars` - Remove leading non-alphabetic characters (default: `false`)
95+
96+
### `isValidIdentifier(key: string): boolean`
97+
98+
Checks if a string is a valid JavaScript identifier (follows standard naming rules).
99+
100+
### `isValidIdentifierCamelized(key: string): boolean`
101+
102+
Checks if a string can be transformed into a valid JavaScript identifier (allows internal hyphens that will be removed during camelization).
103+
104+
## Design Philosophy
105+
106+
komoji embraces simplicity:
107+
- 🎯 Zero dependencies
108+
- 🪶 Tiny footprint
109+
- 🚀 Fast and predictable
110+
- 💎 Pure functions
111+
- 📖 Clear, focused API
112+
113+
## Developing
114+
115+
When first cloning the repo:
116+
117+
```sh
118+
pnpm install
119+
pnpm build
120+
```
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "@interweb/casing",
2+
"name": "komoji",
33
"version": "0.7.2",
44
"author": "Dan Lynch <[email protected]>",
5-
"description": "Interweb casing utils",
5+
"description": "the tiny case transformer — effortlessly transform strings between naming conventions",
66
"main": "index.js",
77
"module": "esm/index.js",
88
"types": "index.d.ts",
@@ -28,5 +28,19 @@
2828
"test": "jest",
2929
"test:watch": "jest --watch"
3030
},
31-
"keywords": []
31+
"keywords": [
32+
"case",
33+
"camelCase",
34+
"PascalCase",
35+
"kebab-case",
36+
"snake_case",
37+
"naming",
38+
"conventions",
39+
"transform",
40+
"convert",
41+
"string",
42+
"identifier",
43+
"codegen",
44+
"utility"
45+
]
3246
}

0 commit comments

Comments
 (0)