All Projects → danielberkompas → Destructure

danielberkompas / Destructure

Licence: mit
Javascript-style destructuring for Elixir

Programming Languages

elixir
2628 projects

Labels

Projects that are alternatives of or similar to Destructure

Stripity stripe
An Elixir Library for Stripe
Stars: ✭ 597 (+556.04%)
Mutual labels:  hex
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
Unicopy
Unicode command-line codepoint dumper
Stars: ✭ 16 (-82.42%)
Mutual labels:  hex
Mssqlex
Microsoft SQL Server Adapter for Elixir
Stars: ✭ 38 (-58.24%)
Mutual labels:  hex
Xxv
The XXV visual hex viewer for the terminal.
Stars: ✭ 61 (-32.97%)
Mutual labels:  hex
Pigeon
iOS and Android push notifications for Elixir
Stars: ✭ 480 (+427.47%)
Mutual labels:  hex
Phoenix gon
🔥 Phoenix variables in your JavaScript without headache.
Stars: ✭ 84 (-7.69%)
Mutual labels:  hex
Telephonist
Elixir state machines for Twilio calls
Stars: ✭ 38 (-58.24%)
Mutual labels:  hex
Exrm deb
Create a deb for your elixir release with ease
Stars: ✭ 75 (-17.58%)
Mutual labels:  hex
Wobserver
Web based metrics, monitoring, and observer
Stars: ✭ 900 (+889.01%)
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
Colorpicker
A mininal but complete colorpicker desktop app
Stars: ✭ 766 (+741.76%)
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

Hex.pm Build Status

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].