dynamic v0.1.2 Dynamic
Provides useful tooling when manipulating complex maps
Link to this section Summary
Functions
Deep merge the right argument into the left
Default to fallback if input is nil
Defaults to fallback if input is compare
Delete the value at the given path
Gets value at path or falls back
Gets value at path or falls back
Traverses map recursively and returns every child map and its path
Returns input stripped of child maps
Set the value at the given path
Link to this section Functions
atom_keys(input)
combine(left, right)
Deep merge the right argument into the left
Examples
iex> Dynamic.combine(%{a: 1}, %{b: 1})
%{a: 1, b: 1}
default(input, fallback)
Default to fallback if input is nil
Examples
iex> Dynamic.default(nil, :foo)
:foo
default(input, fallback, compare)
Defaults to fallback if input is compare
Examples
iex> Dynamic.default(:bar, :foo, :bar)
:foo
delete(input, list)
Delete the value at the given path
Examples
iex> Dynamic.put(%{}, [:a, :b, :c], :foo)
%{a: %{b: %{c: :foo}}}
flatten(input, path \\ [])
get(input, path)
get(map(), Enumerable.t()) :: any()
get(map(), Enumerable.t()) :: any()
Gets value at path or falls back
Examples
iex> Dynamic.get(%{a: %{b: 1}}, [:a, :b])
1
get(input, path, fallback)
Gets value at path or falls back
Examples
iex> Dynamic.get(%{a: %{b: 1}}, [:a, :b, :c], :foo)
:foo
layers(input, path \\ [])
Traverses map recursively and returns every child map and its path
Examples
iex> Dynamic.layers(%{a: 1, child: %{b: 1}})
[
{
[],
%{a: 1, child: %{b: 1}}
},
{
[:child],
%{b: 1}
}
]
primitives(input)
Returns input stripped of child maps
Examples
iex> Dynamic.primitives(%{a: 1, child: %{%{a: 1}
put(input, list, value)
Set the value at the given path
Example
iex> Dynamic.put(%{}, [:a, :b, :c], :foo)
%{a: %{b: %{c: :foo}}}