potion v0.0.3 Potion

Summary

Functions

Determines if the value is empty

Examples

Examples

Functions

empty?(data)
empty?(any) :: boolean

Determines if the value is empty.

Examples

iex> Potion.empty?([])
true
iex> Potion.empty?(%{})
true
iex> Potion.empty?({})
true
iex> Potion.empty?("")
true
iex> Potion.empty?(nil)
true
iex> Potion.empty?(false)
true

iex> Potion.empty?([1,2])
false
iex> Potion.empty?(%{map: "some content"})
false
iex> Potion.empty?({1, 2})
false
iex> Potion.empty?("some content")
false
iex> Potion.empty?(1)
false
iex> Potion.empty?(true)
false
get(data, key, default \\ nil)
get(any, String.t | Integer.t | Atom.t, any) :: any

Examples

iex> Potion.get([1,2,3], 0)
1
iex> Potion.get([1,2,3], 4)
nil
iex> Potion.get({1,2,3}, 0)
1
iex> Potion.get(%{map: "some content"}, :map)
"some content"
iex> Potion.get([1,2,3], 4, 0)
0
put(data, item)
put(Map.t | List.t | Tuple.t, any) ::
  Map.t |
  List.t |
  Tuple.t

Examples

iex> Potion.put([1], 2)
[1,2]
iex> Potion.put([1], [2])
[1,2]
iex> Potion.put(%{map: "some content"}, add: "some content")
%{map: "some content", add: "some content"}
iex> Potion.put(%{map: "some content"}, [add: "some content"])
%{map: "some content", add: "some content"}
iex> Potion.put(%{map: "some content"}, %{add: "some content"})
%{map: "some content", add: "some content"}
iex> Potion.put(%{map: "some content"}, %{map: "some content!"})
%{map: "some content!"}
iex> Potion.put({1,2,3}, 4)
{1,2,3,4}
put_first(data, item)
put_first(Map.t | List.t | Tuple.t, any) ::
  Map.t |
  List.t |
  Tuple.t

Examples

iex> Potion.put_first([1], 2)
[2,1]
iex> Potion.put_first([1], [2])
[2,1]
iex> Potion.put_first(%{map: "some content"}, add: "some content")
%{add: "some content", map: "some content"}
iex> Potion.put_first(%{map: "some content"}, [add: "some content"])
%{add: "some content", map: "some content"}
iex> Potion.put_first(%{map: "some content"}, %{add: "some content"})
%{add: "some content", map: "some content"}
iex> Potion.put_first(%{map: "some content"}, %{map: "some content!"})
%{map: "some content"}
iex> Potion.put_first({1,2,3}, 4)
{4,1,2,3}
trim(data)
trim(Map.t | List.t | Tuple.t) :: Map.t | List.t | Tuple.t

Examples

iex> assert Potion.trim([1,"",3])
[1,3]
iex> Potion.trim(%{map: "some content", map2: ""})
%{map: "some content"}
iex> Potion.trim({1, ""})
{1}