potion v1.1.1 Potion
Summary
Functions
check empty
Gets the value for a specific key
Puts the given value
Puts the given value
Collection trim
Deletes the given value from key
Deletes the given value from value
Functions
check empty
Examples
Potion.empty?([])
true
Potion.empty?(%{})
true
Potion.empty?({})
true
Potion.empty?("")
true
Potion.empty?(nil)
true
Potion.empty?(false)
true
Potion.empty?([1,2])
false
Potion.empty?(%{map: "some content"})
false
Potion.empty?({1, 2})
false
Potion.empty?("some content")
false
Potion.empty?(1)
false
Potion.empty?(true)
false
Gets the value for a specific key
Examples
Potion.get([1,2,3], 0)
1
Potion.get([1,2,3], 4)
nil
Potion.get({1,2,3}, 0)
1
Potion.get([index: 1, index2: 2], :index2)
2
Potion.get({:ok, "some content"}, :ok)
"some content"
Potion.get(%{map: "some content"}, :map)
"some content"
Potion.get([1,2,3], 4, 0)
0
Puts the given value
Examples
Potion.put([1], 2)
[1,2]
Potion.put([1], [2])
[1,2]
Potion.put(%{map: "some content"}, add: "some content")
%{map: "some content", add: "some content"}
Potion.put(%{map: "some content"}, [add: "some content"])
%{map: "some content", add: "some content"}
Potion.put(%{map: "some content"}, %{add: "some content"})
%{map: "some content", add: "some content"}
Potion.put(%{map: "some content"}, %{map: "some content!"})
%{map: "some content!"}
Potion.put({1,2,3}, 4)
{1,2,3,4}
Puts the given value
Examples
Potion.put_first([1], 2)
[2,1]
Potion.put_first([1], [2])
[2,1]
Potion.put_first(%{map: "some content"}, add: "some content")
%{add: "some content", map: "some content"}
Potion.put_first(%{map: "some content"}, [add: "some content"])
%{add: "some content", map: "some content"}
Potion.put_first(%{map: "some content"}, %{add: "some content"})
%{add: "some content", map: "some content"}
Potion.put_first(%{map: "some content"}, %{map: "some content!"})
%{map: "some content"}
Potion.put_first({1,2,3}, 4)
{4,1,2,3}
Collection trim
Examples
Potion.trim([1,"",3])
[1,3]
Potion.trim(%{map: "some content", map2: ""})
%{map: "some content"}
Potion.trim({1, ""})
{1}
Deletes the given value from key
Examples
Potion.unset([1,2], 0)
[2]
Potion.unset(%{a: 1, b: 2}, :a)
%{b: 2}
Potion.unset({1,2}, 0)
{2}
Potion.unset([1,2], [0,1])
[]
Potion.unset(%{a: 1, b: 2}, [:a, :b])
%{}
Potion.unset({1,2}, [1,2])
{1}