Giter Site home page Giter Site logo

name-caser's Introduction

name-caser

String Extension methods to convert PascalCasing to other_casings, taking into account abbreviations.

NuGet version (NameCaser)

Pascal case is a naming convention where the first letter of each word in a variable is capitalized, while the remaining letters are in lowercase. Examples:

  • PascalCase
  • SomeUTPCable

Usage examples:

using NameCaser;

var simple = "SomeSimpleString";
Console.WriteLine(simple.ToCamelCase());         // someSimpleString
Console.WriteLine(simple.ToSnakeCase());         // some_simple_string
Console.WriteLine(simple.ToKebabCase());         // some-simple-string
Console.WriteLine(simple.ToSpaceCase());         // Some simple string
Console.WriteLine(simple.ToConstantCase());      // SOME_SIMPLE_STRING
Console.WriteLine(simple.ToTrainCase());         // Some-Simple-String

var ioDriver = "IODriver";
Console.WriteLine(ioDriver.ToCamelCase());        // ioDriver
Console.WriteLine(ioDriver.ToSnakeCase());        // io_driver
Console.WriteLine(ioDriver.ToKebabCase());        // io-driver
Console.WriteLine(ioDriver.ToSpaceCase());        // IO driver
Console.WriteLine(ioDriver.ToConstantCase());     // IO_DRIVER
Console.WriteLine(ioDriver.ToTrainCase());        // IO-Driver

var someUTPCable = "SomeUTPCable";
Console.WriteLine(someUTPCable.ToCamelCase());    // someUTPCable
Console.WriteLine(someUTPCable.ToSnakeCase());    // some_utp_cable
Console.WriteLine(someUTPCable.ToKebabCase());    // some-utp-cable
Console.WriteLine(someUTPCable.ToSpaceCase());    // Some UTP cable
Console.WriteLine(someUTPCable.ToConstantCase()); // SOME_UTP_CABLE
Console.WriteLine(someUTPCable.ToTrainCase());    // Some-UTP-Cable

//Bonus: ToPascal() Method
var somePhrase = " - Some UTP cable "
Console.WriteLine(somePhrase.ToPascalCase());     // SomeUTPCable
Console.WriteLine(somePhrase.ToPascalCase()
                            .ToKebabCase());      // some-utp-cable

Supports the conversion to the following casings

1. camelCase

Camel Case is actually inspired from animal “Camel”. Where first word will be small letters and from second word, first character will be captialized like camelCase.

Camel Case is often used for property Naming in typescript

2. snake_case

Snake Case is naming with words separated by _ ( underscore ) and all small letters

Snake Case is often used for file Naming

3. kebab-case

Kebab Case is naming with words separated by — ( hyphen ) with all small letters

Kebab Case is often used for CSS naming

4. Space case

Space case is naming with words separated by ' ' ( space ) and all small letters

Space Case is often used auto generating comments

5. CONSTANT_CASE

Constant case is naming with all letters Capitalized but the words are separated by _ ( underscore)

Constant case is often used for constants and macros

6. Train-Case

Train Case is naming with first character of every word of name is Capitalised and words are connected with — ( hyphen ).

Train Case is also often used for file Naming

name-caser's People

Contributors

crwsolutions avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.