Zodish.Helpers (zodish v0.2.4)
View SourceCommon utility functions.
Summary
Functions
Alias to Kernel.inspect/1.
Infers the type of a value, returning its spec's AST.
Pluralizes a given word based on common English rules.
Pluralizes a word based on the given count.
Same as Keyword.take/2 but the keys are sorted in the same order
you provided them.
Returns the name of the given module without the "Elixir." prefix.
Returns the type of the given value.
Prints a warning message the returns the value given as first argument.
Functions
Alias to Kernel.inspect/1.
Infers the type of a value, returning its spec's AST.
Pluralizes a given word based on common English rules.
iex> pluralize("is")
"are"
iex> pluralize("Was")
"Were"
iex> pluralize("cat")
"cats"
iex> pluralize("baby")
"babies"
iex> pluralize("box")
"boxes"
iex> pluralize("leaf")
"leaves"
iex> pluralize("man")
"men"
iex> pluralize("church")
"churches"
@spec pluralize(count :: non_neg_integer(), word :: String.t()) :: String.t()
Pluralizes a word based on the given count.
iex> pluralize(1, "cat")
"cat"
iex> pluralize(0, "cat")
"cats"
iex> pluralize(2, "cat")
"cats"
Same as Keyword.take/2 but the keys are sorted in the same order
you provided them.
iex> value =[foo: 1, bar: 2, baz: 3]
iex> take_sorted(value, [:bar, :baz, :foo])
[bar: 2, baz: 3, foo: 1]
Returns the name of the given module without the "Elixir." prefix.
iex> to_string(Zodish.Type.Map)
"Elixir.Zodish.Type.Map"
iex> to_mod_name(Zodish.Type.Map)
"Zodish.Type.Map"
@spec typeof(value) :: String.t() when value: nil | boolean() | atom() | binary() | bitstring() | float() | integer() | list() | keyword() | struct() | map() | tuple() | function() | pid() | port() | reference()
Returns the type of the given value.
Prints a warning message the returns the value given as first argument.