1- # @interweb/inflection
2-
3- Inflection utilities for pluralization and singularization with PostGraphile-compatible Latin suffix handling.
1+ # inflekt
2+
3+ <p align =" center " >
4+ <img src =" https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg " height =" 250 " >
5+ <br />
6+ <strong>smart pluralization and inflection for the modern web</strong>
7+ <br />
8+ <br />
9+ Inflection utilities for pluralization and singularization with PostGraphile-compatible Latin suffix handling
10+ <br />
11+ <br />
12+ <a href =" https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml " >
13+ <img height="20" src="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml/badge.svg" />
14+ </a >
15+ <a href =" https://github.com/constructive-io/dev-utils/blob/main/LICENSE " >
16+ <img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
17+ </a >
18+ </p >
419
520## Installation
621
722``` bash
8- npm install @interweb/inflection
23+ npm install inflekt
924```
1025
1126## Usage
@@ -19,9 +34,16 @@ import {
1934 distinctPluralize ,
2035 lcFirst ,
2136 ucFirst ,
37+ camelize ,
38+ underscore ,
39+ toPascalCase ,
40+ toCamelCase ,
41+ toSnakeCase ,
42+ toKebabCase ,
43+ toConstantCase ,
2244 toFieldName ,
2345 toQueryName ,
24- } from ' @interweb/inflection ' ;
46+ } from ' inflekt ' ;
2547
2648// Basic singularization/pluralization
2749singularize (' Users' ); // 'User'
@@ -36,10 +58,22 @@ singularize('Media'); // 'Medium'
3658singularizeLast (' UserProfiles' ); // 'UserProfile'
3759pluralizeLast (' UserProfile' ); // 'UserProfiles'
3860
39- // Case transformations
61+ // First character case transformations
4062lcFirst (' UserProfile' ); // 'userProfile'
4163ucFirst (' userProfile' ); // 'UserProfile'
4264
65+ // Snake case / camel case conversions
66+ camelize (' user_profile' ); // 'UserProfile'
67+ camelize (' user_profile' , true ); // 'userProfile'
68+ underscore (' UserProfile' ); // 'user_profile'
69+
70+ // Full case transformations (re-exported from komoji)
71+ toPascalCase (' hello-world' ); // 'HelloWorld'
72+ toCamelCase (' hello-world' ); // 'helloWorld'
73+ toSnakeCase (' helloWorld' ); // 'hello_world'
74+ toKebabCase (' HelloWorld' ); // 'hello-world'
75+ toConstantCase (' helloWorld' ); // 'HELLO_WORLD'
76+
4377// GraphQL naming helpers
4478toFieldName (' Users' ); // 'user'
4579toQueryName (' User' ); // 'users'
@@ -60,7 +94,14 @@ toQueryName('User'); // 'users'
6094
6195- ` lcFirst(str) ` - Convert first character to lowercase (PascalCase to camelCase)
6296- ` ucFirst(str) ` - Convert first character to uppercase (camelCase to PascalCase)
97+ - ` camelize(str, lowFirstLetter?) ` - Convert snake_case to PascalCase (or camelCase if lowFirstLetter is true)
98+ - ` underscore(str) ` - Convert PascalCase/camelCase to snake_case
6399- ` fixCapitalisedPlural(str) ` - Fix capitalized S after numbers (e.g., ` Table1S ` -> ` Table1s ` )
100+ - ` toPascalCase(str) ` - Convert to PascalCase (re-exported from komoji)
101+ - ` toCamelCase(str) ` - Convert to camelCase (re-exported from komoji)
102+ - ` toSnakeCase(str) ` - Convert to snake_case (re-exported from komoji)
103+ - ` toKebabCase(str) ` - Convert to kebab-case (re-exported from komoji)
104+ - ` toConstantCase(str) ` - Convert to CONSTANT_CASE (re-exported from komoji)
64105
65106### Naming Helpers
66107
0 commit comments