lodash v0.0.3 Lodash.String

Specialized functions to manipulate Strings.

Summary

Functions

Converts str to camel case

Deburrs str by converting unicode into ascii

Converts str to kebab case

Converts str to lower case

Convert str by to pascal case

Converts str to snake case

Converts str to start case

Truncates str if it’s longer than the given maximum string length. The last characters of the truncated string are replaced with the omission string which defaults to “…”

Functions

camel_case(str)

Converts str to camel case

Examples

iex> Lodash.String.camel_case("Foo Bar")
"fooBar"
iex> Lodash.String.camel_case("--foo-bar--")
"fooBar"
iex> Lodash.String.camel_case("__FOO_BAR__")
"fooBar"
deburr(str)

Deburrs str by converting unicode into ascii.

Examples

iex> Lodash.String.deburr("minh quý")
"minh quy"
kebab_case(str)

Converts str to kebab case

Examples

iex> Lodash.String.kebab_case("Foo Bar")
"foo-bar"
iex> Lodash.String.kebab_case("--foo-bar--")
"foo-bar"
iex> Lodash.String.kebab_case("__FOO_BAR__")
"foo-bar"
lower_case(str)

Converts str to lower case

Examples

iex> Lodash.String.lower_case("Foo Bar")
"foo bar"
iex> Lodash.String.lower_case("--foo-bar--")
"foo bar"
iex> Lodash.String.lower_case("__FOO_BAR__")
"foo bar"
pascal_case(str)

Convert str by to pascal case.

Examples

iex> Lodash.String.pascal_case("Foo Bar")
"FooBar"
iex> Lodash.String.pascal_case("--foo-bar--")
"FooBar"
iex> Lodash.String.pascal_case("__FOO_BAR__")
"FooBar"
snake_case(str)

Converts str to snake case

Examples

iex> Lodash.String.snake_case("Foo Bar")
"foo_bar"
iex> Lodash.String.snake_case("--foo-bar--")
"foo_bar"
iex> Lodash.String.snake_case("__FOO_BAR__")
"foo_bar"
start_case(str)

Converts str to start case

Examples

iex> Lodash.String.start_case("Foo Bar")
"Foo Bar"
iex> Lodash.String.start_case("--foo-bar--")
"Foo Bar"
iex> Lodash.String.start_case("__FOO_BAR__")
"Foo Bar"
truncate(str, options \\ [])

Truncates str if it’s longer than the given maximum string length. The last characters of the truncated string are replaced with the omission string which defaults to “…”

Examples

iex> Lodash.String.truncate("hi-minh quy")
"hi-minh quy"
iex> Lodash.String.truncate("hi-minh quy", length: 4)
"h..."
iex> Lodash.String.truncate("hi-minh quy", length: 10, separator: ~r/ /)
"hi-minh..."
iex> Lodash.String.truncate("hi-minh quy", length: 10, omission: " ...")
"hi-min ..."
words(str, pattern \\ %{__struct__: Regex, opts: "", re_pattern: {:re_pattern, 0, 0, 0, <<69, 82, 67, 80, 105, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>}, source: "[^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]+"})

Split str into an array of its words.

Examples

iex> Lodash.String.words("fred, barney, & pebbles")
["fred", "barney", "pebbles"]
iex> Lodash.String.words("fred, barney, & pebbles", ~r/[^, ]+/)
["fred", "barney", "&", "pebbles"]