Skip to content

Super simple, zero dependency naming convention converter and validator cli/library.

Notifications You must be signed in to change notification settings

TheKhanj/convconv

Repository files navigation

ConvConv

Super simple, zero dependency naming convention converter and validator library.

Cli

As of version 0.3.3 there is cli version of convconv available. Use the following command to install it globally onto your system. npm i -g convconv You can see help for cli by running the following command. convconv --help

Examples

import convconv from "convconv";

// examples:
//   camelCase
//   kebab-case
//   PascalCase
//   snake_case
//   SCREAMING-KEBAB-CASE
//   SCREAMING_SNAKE_CASE

// converts camelCase to kebab-case
// camelCase -> camel-case
convconv.fromCamel("camelCase").toKebab();

// converts kebab-case to snake_case
// kebab-case -> kebab_case
convconv.fromConvention("kebab", "kebab-case").toSnake();

// converts any case to PascalCase
convconv
  .autoFrom("your-input-in-one-of-available-naming-conventions")
  .toPascal();

// throws ConventionNotFoundError
convconv.autoFrom("Random_sTring-with_nOConvention");

// returns 'kebab'
convconv.getConvention("some-kebab-case-string");

// throws ConventionNotFoundError
convconv.getConvention("Random_sTring-with_nOConvention");

// returns true
convconv.isPascal("PascalCase");

// returns true
convconv.isConvention("pascal", "PascalCase");

// throws ConventionViolationError
convconv.fromKebab("NotKebab");

// throws ConventionViolationError
convconv.fromCamel("123startingWithNumber");

Errors

All errors extend from ConvConvError.

About

Super simple, zero dependency naming convention converter and validator cli/library.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published