potion v1.0.0 Potion
Summary
Functions
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
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({:ok, "some content"}, :ok)
"some content"
iex> Potion.get(%{map: "some content"}, :map)
"some content"
iex> Potion.get([1,2,3], 4, 0)
0
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}
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}
Examples
iex> assert Potion.trim([1,"",3])
[1,3]
iex> Potion.trim(%{map: "some content", map2: ""})
%{map: "some content"}
iex> Potion.trim({1, ""})
{1}
Examples
iex> Potion.unset([1,2], 0)
[2]
iex> Potion.unset(%{a: 1, b: 2}, :a)
%{b: 2}
iex> Potion.unset({1,2}, 0)
{2}
iex> Potion.unset([1,2], [0,1])
[]
iex> Potion.unset(%{a: 1, b: 2}, [:a, :b])
%{}
iex> Potion.unset({1,2}, [1,2])
{1}