DarkMatter.Maps (DarkMatter v1.1.4) View Source
Utils for handling maps
Link to this section Summary
Functions
Safe version of Kernel.get_in/2
Determine if a map
keys are of type atom/0
.
Returns a map with nil values omitted
Determine if a map
keys are of type atom/0
.
Provide indifferent access to maps.
Determine if a map
keys are of type atom/0
.
Returns a sorted list of atom keys found in results
.
Determine if a map
keys are of type String.t/0
.
Classifies a map by key type.
Classifies a kv
pair by key type.
Link to this section Types
Specs
Specs
access_key_or_keys() :: access_key() | [access_key(), ...]
Specs
Specs
iget_key() :: atom()
Specs
Specs
kv_type() :: :atom | :string | :complex
Specs
map_keys_type() :: kv_type() | :mixed | :empty
Link to this section Functions
Specs
access_in(map(), access_key_or_keys(), any()) :: any()
Safe version of Kernel.get_in/2
Specs
Determine if a map
keys are of type atom/0
.
Examples
iex> atom_keys?(%{})
true
iex> atom_keys?(%URI{})
true
iex> atom_keys?(%{atom: true})
true
iex> atom_keys?(%{"string" => true})
false
iex> atom_keys?(%{[] => "complex"})
false
iex> atom_keys?(%{:atom => true, "string" => true})
false
Specs
Returns a map with nil values omitted
Specs
Determine if a map
keys are of type atom/0
.
Examples
iex> complex_keys?(%{})
true
iex> complex_keys?(%URI{})
false
iex> complex_keys?(%{atom: true})
false
iex> complex_keys?(%{"string" => true})
false
iex> complex_keys?(%{[] => "complex"})
true
iex> complex_keys?(%{:atom => true, "string" => true})
false
Specs
iget(map(), accessor_path()) :: any()
Provide indifferent access to maps.
Specs
iget(map(), accessor_path(), any()) :: any()
Specs
Determine if a map
keys are of type atom/0
.
Examples
iex> mixed_keys?(%{})
true
iex> mixed_keys?(%URI{})
false
iex> mixed_keys?(%{atom: true})
false
iex> mixed_keys?(%{"string" => true})
false
iex> mixed_keys?(%{[] => "complex"})
false
iex> mixed_keys?(%{:atom => true, "string" => true})
true
Specs
Returns a sorted list of atom keys found in results
.
Specs
Determine if a map
keys are of type String.t/0
.
Examples
iex> string_keys?(%{})
true
iex> string_keys?(%URI{})
false
iex> string_keys?(%{atom: true})
false
iex> string_keys?(%{"string" => true})
true
iex> string_keys?(%{[] => "complex"})
false
iex> string_keys?(%{:atom => true, "string" => true})
false
Specs
typeof_keys(map() | struct()) :: map_keys_type()
Classifies a map by key type.
Examples
iex> typeof_keys(%{})
:empty
iex> typeof_keys(%URI{})
:atom
iex> typeof_keys(%{atom: true})
:atom
iex> typeof_keys(%{"string" => true})
:string
iex> typeof_keys(%{[] => "complex"})
:complex
iex> typeof_keys(%{:atom => true, "string" => true})
:mixed
Specs
Classifies a kv
pair by key type.
Examples
iex> typeof_kv({:atom, true})
:atom
iex> typeof_kv({"string", true})
:string
iex> typeof_kv({[], true})
:complex