casbab

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package casbab is a Go library for converting representation style of compound words or phrases. Different writing styles of compound words are used for different purposes in computer code and variables to easily distinguish type, properties or meaning.

Functions in this package are separating words from input string and constructing an appropriate phrase representation.

Examples:

kebab("camel_snake_kebab") == "camel-snake-kebab"
screamingSnake("camel_snake_kebab") == "CAMEL_SNAKE_KEBAB"
camel("camel_snake_kebab") == "camelSnakeKebab"
pascal("camel_snake_kebab") == "CamelSnakeKebab"
snake("camelSNAKEKebab") == "camel_snake_kebab"

Word separation works by detecting delimiters hyphen (-), underscore (_), space ( ) and letter case change.

Note: Leading and trailing separators will be preserved only within the Snake family or within the Kebab family and not across them. This restriction is based on different semantics between different writings.

Examples:

titleSnake("__camel_snake_kebab__") == "__Camel_Snake_Kebab__"
kebab("__camel_snake_kebab") == "camel-snake-kebab"
screaming("__camel_snake_kebab") == "CAMEL SNAKE KEBAB"
titleKebab("--camel-snake-kebab") == "--Camel-Snake-Kebab"
snake("--camel-snake-kebab") == "camel_snake_kebab"
screaming("--camel-snake-kebab") == "CAMEL SNAKE KEBAB"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Find

func Find(s string) func(string) string

Find returns the function based on the capitalization scheme desired, or nil if it doesn't recognize the scheme.

The complete list:

  • "two words" aliases: "lower case"
  • "two-words" aliases: "kebab-case"
  • "two-Words" aliases: "camel-Kebab-Case"
  • "two_words" aliases: "snake_case"
  • "two_Words" aliases: "camel_Snake_Case"
  • "twowords" aliases: "flatcase"
  • "twoWords" aliases: "camelCase"
  • "Two Words" aliases: "Title Case"
  • "Two-Words" aliases: "Pascal-Kebab-Case", "Title-Kebab-Case"
  • "Two_Words" aliases: "Pascal_Snake_Case", "Title_Snake_Case"
  • "TwoWords" aliases: "PascalCase"
  • "TWO WORDS" aliases: "SCREAMING CASE"
  • "TWO-WORDS" aliases: "SCREAMING-KEBAB-CASE"
  • "TWO_WORDS" aliases: "SCREAMING_SNAKE_CASE"
  • "TWOWORDS" aliases: "UPPERCASE"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL