Pipette.Control (pipette_elixir v0.1.3)

Pipe control combinators.

Summary

Functions

Pipe-friendly dbg/1 wrapper controlled by a predicate.

Run fun.(value) without changing the value.

Pattern-match inside a pipeline while keeping it flowing.

Inverse of pipe_when.

If cond truthy, apply fun; else pass through.

Functions

dbg_when(value, cond)

@spec dbg_when(any(), boolean()) :: any()

Pipe-friendly dbg/1 wrapper controlled by a predicate.

value |> dbg_when(Mix.env() == :dev)

do_tap(value, fun)

@spec do_tap(any(), (any() -> any())) :: any()

Run fun.(value) without changing the value.

pipe_case(value, list)

(macro)

Pattern-match inside a pipeline while keeping it flowing.

user
|> pipe_case do
     %{email: e} -> String.downcase(e)
     _           -> nil
   end

pipe_unless(value, cond, fun)

@spec pipe_unless(any(), any(), (any() -> any())) :: any()

Inverse of pipe_when.

pipe_when(value, cond, fun)

@spec pipe_when(any(), any(), (any() -> any())) :: any()

If cond truthy, apply fun; else pass through.