All Projects → wemake-services → recase

wemake-services / recase

Licence: MIT License
♻️ Convert strings to any case.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to recase

axios-case-converter
Axios transformer/interceptor that converts snake_case/camelCase
Stars: ✭ 114 (-37.7%)
Mutual labels:  snake-case, camelcase
stringy
Convert string to camel case, snake case, kebab case / slugify, custom delimiter, pad string, tease string and many other functionalities with help of by Stringy package.
Stars: ✭ 137 (-25.14%)
Mutual labels:  snake-case, camelcase
python-string-utils
A handy Python library to validate, manipulate and generate strings
Stars: ✭ 47 (-74.32%)
Mutual labels:  snake-case, camelcase
pascalcase
Convert a string to pascal case (upper camel case). Used by more than 8.7 million projects on GitHub! Please follow this library's author: https://github.com/jonschlinkert
Stars: ✭ 35 (-80.87%)
Mutual labels:  camelcase, pascalcase
camelcaseplugin
CamelCasePlugin for IDEA IDEs
Stars: ✭ 49 (-73.22%)
Mutual labels:  snake-case, camelcase
covid19 ch
covid19 map for Switzerland using Esri Maps.
Stars: ✭ 24 (-86.89%)
Mutual labels:  cases
Testcase-Generator
⚡️ Handy script for HackerRank, HackerEarth and CodeChef TCs Generation.
Stars: ✭ 85 (-53.55%)
Mutual labels:  cases
spiral
A Python 3 module that provides functions for splitting identifiers found in source code files.
Stars: ✭ 37 (-79.78%)
Mutual labels:  camelcase
sklonenie
Light-weight and fast library to decline Russian names
Stars: ✭ 23 (-87.43%)
Mutual labels:  cases
case-converter
Convert strings between 13 naming conventions: Snake case, Camel case, Kebab case, Pascal case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Title case, Sentence case and Dot notation.
Stars: ✭ 148 (-19.13%)
Mutual labels:  snake-case
Suitecrm
SuiteCRM - Open source CRM for the world
Stars: ✭ 2,770 (+1413.66%)
Mutual labels:  cases
go-strcase
Convert snake case, camel case and kebap case strings
Stars: ✭ 66 (-63.93%)
Mutual labels:  snake-case

Recase

Recase

Build Status Coverage Status Hex Version Hex Docs Total Download License Last Updated

Recase helps you to convert a string from any case to any case.

Why?

One can ask: "Why should I use Recase when I can use built-in Macro module?". But, you have to keep in mind that Macro's functions are not suitable for general case usage:

Do not use it as a general mechanism for underscoring or camelizing strings as it does not support Unicode or characters that are not valid in Elixir identifiers.

Installation

def deps do
  [
    {:recase, "~> 0.5"}
  ]
end

Usage

Pascal

Pascal (or Upper) case uses mixed case with lower and upper cased characters. Separates words from each other with the upper case letters. Starts with upper case letter.

Recase.to_pascal("some-value") # => "SomeValue"
Recase.to_pascal("Some value") # => "SomeValue"

Camel

Camel case uses mixed case with lower and upper cased characters. Separates words from each other with the upper cased letters. Starts with lower case letter.

Recase.to_camel("some-value") # => "someValue"
Recase.to_camel("Some Value") # => "someValue"

Snake

Snake cases uses all lower case. Uses _ as a separator.

Recase.to_snake("someValue") # => "some_value"
Recase.to_snake("Some Value") # => "some_value"

Kebab

Kebab cases uses all lower case. Uses - as a separator.

Recase.to_kebab("someValue") # => "some-value"
Recase.to_kebab("Some Value") # => "some-value"

Constant

Constant case uses all upper case. Uses _ as a separator.

Recase.to_constant("SomeValue") # => "SOME_VALUE"
Recase.to_constant("some value") # => "SOME_VALUE"

Dot

Dot case uses all lower case similar to snake case. Uses . as a separator.

Recase.to_dot("SomeValue") # => "some.value"
Recase.to_dot("some value") # => "some.value"

Path

Path case preserves case, you can also provide a separator as the second argument.

Recase.to_path("SomeValue") # => "Some/Value"
Recase.to_path("some value", "\\") # => "some\\value"

Sentence

Sentence case uses the same rules as regular sentence. First letter is uppercase all others letters are lowercase separated by spaces.

Recase.to_sentence("SomeValue") # => "Some value"
Recase.to_sentence("some value") # => "Some value"

Title

Title case applies a "Title Style" to all words in a sentence.

Recase.to_title("some-value") # => "Some Value"
Recase.to_title("some value") # => "Some Value"

Header

Header case uses the same case as PascalCase, while using - as a separator.

Recase.to_header("SomeValue") # => "Some-Value"
Recase.to_header("some value") # => "Some-Value"

Enumerable

You can convert all keys in an enumerable with:

Recase.Enumerable.convert_keys(
  %{"yourKey" => "value"},
  &Recase.to_snake/1
) # => %{"your_key" => "value"}

Recase.Enumerable.convert_keys(
  %{"your_key" => "value"},
  &Recase.to_camel/1
) # => %{"yourKey" => "value"}

Recase.Enumerable.atomize_keys(
  %{"yourKey" => "value"},
  &Recase.to_snake/1
) # => %{your_key: "value"}

Recase.Enumerable.atomize_keys(
  %{"your_key" => "value"},
  &Recase.to_camel/1
) # => %{yourKey: "value"}

Changelog

Full changelog is available here.

Copyright and License

Copyright (c) 2017 Nikita Sobolev

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE.md file for more details.

Thanks

Thanks to Gyan Lakhwani for the logo.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].