danielberkompas / Destructure
Licence: mit
Javascript-style destructuring for Elixir
Stars: ✭ 91
Programming Languages
elixir
2628 projects
Labels
Projects that are alternatives of or similar to Destructure
Vim Hexedit
Hexedit is a plug-in under VIM, which is used to strengthen the hex editing ability of VIM.
Stars: ✭ 42 (-53.85%)
Mutual labels: hex
Colorhighlight
🎨 Lightweight Color Highlight colorizer for Sublime Text
Stars: ✭ 76 (-16.48%)
Mutual labels: hex
Phoenix gon
🔥 Phoenix variables in your JavaScript without headache.
Stars: ✭ 84 (-7.69%)
Mutual labels: hex
Renew
Mix task to create mix projects that builds into Docker containers.
Stars: ✭ 33 (-63.74%)
Mutual labels: hex
Alpine Phoenix Builder
Up to date Alpine image with the latest language versions for staged Elixir and Phoenix builds.
Stars: ✭ 71 (-21.98%)
Mutual labels: hex
Coherence
Coherence is a full featured, configurable authentication system for Phoenix
Stars: ✭ 1,207 (+1226.37%)
Mutual labels: hex
Ethereumjs Util
Project is in active development and has been moved to the EthereumJS monorepo.
Stars: ✭ 534 (+486.81%)
Mutual labels: hex
Galvanise zero
Learning from zero (mostly based off of AlphaZero) in General Game Playing.
Stars: ✭ 60 (-34.07%)
Mutual labels: hex
Multiverse
Elixir package that allows to add compatibility layers via API gateways.
Stars: ✭ 87 (-4.4%)
Mutual labels: hex
Xcodecolorsense
🎈 An Xcode plugin that makes working with color easier
Stars: ✭ 79 (-13.19%)
Mutual labels: hex
Ex admin
ExAdmin is an auto administration package for Elixir and the Phoenix Framework
Stars: ✭ 1,180 (+1196.7%)
Mutual labels: hex
Destructure
Adds Javascript-style destructuring to Elixir. When working with map
, instead
of writing match operation like this:
def full_name(%{first_name: first_name, last_name: last_name}) do
"#{first_name} #{last_name}"
end
You can write:
import Destructure
def full_name(d%{first_name, last_name}) do
"#{first_name} #{last_name}"
end
It also works with structs
and keyword
.
import Destructure
def full_name(d%Person{first_name, last_name}) do
"#{first_name} #{last_name}"
end
def full_name(d[first_name, last_name]) do
"#{first_name} #{last_name}"
end
You can also do it in case statement.
case post(url, data) do
{:ok, d%{body}} -> # instead of {:ok, %{body: body}}
# use body variable
_other ->
# ...
end
Unlike Javascript, you can still bind custom variables:
d(%{first, last, email: mail}) = %{...}
See the Hex Documentation for more details.
Installation
Add destructure
to your list of dependencies in mix.exs
:
def deps do
[{:destructure, "~> 0.2.3"}]
end
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].