Collection of Elixir syntactic sugars.
Something like ES6 property shorthand, or Clojure's destructuring. It expands keywords, maps and structs, and supports variable pinning and map update syntax.
For examples look at Synex.Keys.keys/1
.
Like keys/1
but only for maps and uses string keys instead of atoms.
params/1
also expands nested maps.
iex> params(%{a => %{b, c}}) = %{"a" => %{"b" => 2, "c" => 3}}
iex> {b, c}
{2, 3}
iex> a
%{"b" => 2, "c" => 3}
For more examples look at Synex.Params.params/1
.
- Add
synex
to your list of dependencies inmix.exs
:
def deps do
[{:synex, "~> 1.0"}]
end
- Add
use Synex
to your module.