Skip to content

devalz/nomus.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦ Nomus

Nomus is a naming-style toolkit for Node.js and NestJS. It detects the current style of a string and converts it to formats like UPPERCCASE, lowercase, PascalCase, camelCase, snake_case, SCREAMING_SNAKE_CASE, kebab-case, UPPER-KEBAB-CASE, Title Case and Train-Case.

πŸš€ Features

βœ” Convert from any format to:

  • UPPERCCASE
  • lowercase
  • PascalCase
  • camelCase
  • snake_case
  • SCREAMING_SNAKE_CASE
  • kebab-case
  • UPPER-KEBAB-CASE
  • Title Case
  • Train-Case

βœ” Automatically detects:

  • UPPERCCASE
  • lowercase
  • PascalCase
  • camelCase
  • snake_case
  • SCREAMING_SNAKE_CASE
  • kebab-case
  • UPPER-KEBAB-CASE
  • Title Case
  • Train-Case
  • and mixed cases

βœ” Pure TypeScript API for Node.js and TypeScript projects
βœ” Optional NestJS integration exposed as nomus/nest
βœ” ESM, CommonJS, and declaration files ready for npm publishing
βœ” Detects common naming conventions and mixed input
βœ” No runtime dependencies for the core package


πŸ“₯ Installation

npm install nomus

For NestJS integration:

npm install nomus @nestjs/common reflect-metadata

Nomus is compatible with NestJS 10 projects that already use reflect-metadata@0.1.x, and also with reflect-metadata@0.2.x. The nomus/nest entrypoint is also published in a way that works with classic TypeScript moduleResolution: node.

✨ Node.js Usage

import { Naming, detectNamingStyle, toSnakeCase } from "nomus";

detectNamingStyle("votesUsers");
// "camelCase"

toSnakeCase("UserVotesDetails");
// "user_votes_details"

Naming.toTrainCase("helloWorldTest");
// "Hello-World-Test"

✨ NestJS Usage

import { Module } from "@nestjs/common";
import { NomusModule } from "nomus/nest";

@Module({
  imports: [NomusModule]
})
export class AppModule {}
import { Injectable } from "@nestjs/common";
import { NomusService } from "nomus/nest";

@Injectable()
export class SlugService {
  constructor(private readonly nomus: NomusService) {}

  formatLabel(value: string) {
    return this.nomus.toKebabCase(value);
  }
}

🧩 Available Methods


πŸ”€ Naming.*

Static equivalents for all methods

Naming.detectNamingStyle("UserVotesDetails");    // PascalCase
Naming.toTrainCase("userVotesDetails");          // "User-Votes-Details"

πŸ” detectNamingStyle(input)

Automatically detects the naming convention of the text.

Possible results:

  • 'UPPERCASE'
  • 'lowercase'
  • 'PascalCase'
  • 'camelCase'
  • 'snake_case'
  • 'SCREAMING_SNAKE_CASE'
  • 'kebab-case'
  • 'UPPER-KEBAB-CASE'
  • 'Title Case'
  • 'Train-Case'
  • 'Unknown / Mixed'

Examples:

Naming.detectNamingStyle("UserVotesDetails");    // PascalCase
detectNamingStyle("userVotesDetails");           // camelCase
Naming.detectNamingStyle("user_votes_details");  // snake_case
detectNamingStyle("user-votes-details");         // kebab-case
Naming.detectNamingStyle("votes UsersDetails");  // Unknown / Mixed

πŸ”  toUpperCase(input)

Converts from any format to UPPERCASE.


πŸ”‘ toLowerCase(input)

Converts from any format to lowercase.


🧱 toPascalCase(input)

Converts from any format to PascalCase.


πŸͺ toCamelCase(input)

Converts from any format to camelCase.


🐍 toSnakeCase(input)

Converts from any format to snake_case.


πŸπŸ”  toScreamingSnakeCase(input)

Converts from any format to SCREAMING_SNAKE_CASE.


πŸ”— toKebabCase(input)

Converts from any format to kebab-case.


πŸ”—πŸ”  toUpperKebabCase(input)

Converts from any format to UPPER-KEBAB-CASE.


πŸ”€ toTitleCase(input)

Converts from any format to Title Case.


πŸš‚ toTrainCase(input)

Converts from any format to Title Case.


πŸ§ͺ Additional Examples

Naming.toPascalCase("hello-world");       // HelloWorld
toCamelCase("HELLO_WORLD");               // helloWorld
Naming.toSnakeCase("HelloWorld");         // hello_world
toKebabCase("helloWorldTest");            // hello-world-test
Naming.ToTrainCase("helloWorldTest");     // Hello-World-Test

detectNamingStyle("MyVariable");          // PascalCase
Naming.detectNamingStyle("myVariable");   // camelCase
detectNamingStyle("my_variable");         // snake_case
Naming.detectNamingStyle("my-variable");  // kebab-case
detectNamingStyle("My Variable");         // Title Case

πŸ“„ License

This project is licensed under the MIT License, which means you can freely use it in commercial and personal projects.


🀝 Contributing

Contributions are welcome! You can:

  • Report issues
  • Propose improvements
  • Submit PRs

⭐ Support the Project

If this package was useful to you, consider leaving a ⭐ on GitHub or sharing it with other developers.

About

Nomus is a library that allows you to detect the type of writing and convert it according to the convention you need (camelCase, PascalCase, snake_case, etc.).

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors