dynamic v0.1.0 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

Link to this function atom_keys(input)
Link to this function combine(left, right)

Deep merge the right argument into the left

Examples

iex> Dynamic.combine(%{a: 1}, %{b: 1})
%{a: 1, b: 1}
Link to this function default(input, fallback)

Default to fallback if input is nil

Examples

iex> Dynamic.default(nil, :foo)
:foo
Link to this function default(input, fallback, compare)

Defaults to fallback if input is compare

Examples

iex> Dynamic.default(:bar, :foo, :bar)
:foo
Link to this function delete(input, list)

Delete the value at the given path

Examples

iex> Dynamic.put(%{}, [:a, :b, :c], :foo)
%{a: %{b: %{c: :foo}}}
Link to this function flatten(input, path \\ [])
Link to this function get(input, path)
get(map(), Enumerable.t()) :: any()

Gets value at path or falls back

Examples

iex> Dynamic.get(%{a: %{b: 1}}, [:a, :b])
1
Link to this function get(input, path, fallback)

Gets value at path or falls back

Examples

iex> Dynamic.get(%{a: %{b: 1}}, [:a, :b, :c], :foo)
:foo
Link to this function 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}
  }
]
Link to this function primitives(input)

Returns input stripped of child maps

Examples

iex> Dynamic.primitives(%{a: 1, child: %{%{a: 1}
Link to this function put(input, list, value)

Set the value at the given path

Example

iex> Dynamic.put(%{}, [:a, :b, :c], :foo)
%{a: %{b: %{c: :foo}}}
Link to this function string_keys(input)