FunFunc v0.2.0 FunFunc.Value
Functions inspired by Ruby’s ActiveSupport.
Link to this section Summary
Functions
The opposite of present?
Checks the value is empty
The opposite of empty?
It returns the itself when the value is present, or returns nil
Checks the value is present
Returns true
if not false
nor nil
Link to this section Functions
The opposite of present?
.
Examples
iex> FunFunc.Value.blank?(nil)
true
iex> FunFunc.Value.blank?(false)
true
iex> FunFunc.Value.blank?("")
true
iex> FunFunc.Value.blank?(%{})
true
iex> FunFunc.Value.blank?([])
true
iex> FunFunc.Value.blank?(1)
false
Checks the value is empty.
Examples
iex> FunFunc.Value.empty?([])
true
iex> FunFunc.Value.empty?(%{})
true
iex> FunFunc.Value.empty?("")
true
iex> FunFunc.Value.empty?(1)
false
The opposite of truthy?/1
.
Examples
iex> FunFunc.Value.falsy?(1)
false
iex> FunFunc.Value.falsy?(false)
true
iex> FunFunc.Value.falsy?(nil)
true
The opposite of empty?
.
Examples
iex> FunFunc.Value.non_empty?([])
false
iex> FunFunc.Value.non_empty?(%{})
false
iex> FunFunc.Value.non_empty?("")
false
iex> FunFunc.Value.non_empty?(1)
true
Link to this function
presence(x)
It returns the itself when the value is present, or returns nil.
Examples
iex> FunFunc.Value.presence(nil)
nil
iex> FunFunc.Value.presence(false)
nil
iex> FunFunc.Value.presence("")
nil
iex> FunFunc.Value.presence(%{})
nil
iex> FunFunc.Value.presence([])
nil
iex> FunFunc.Value.presence(1)
1
Checks the value is present.
Examples
iex> FunFunc.Value.present?(nil)
false
iex> FunFunc.Value.present?(false)
false
iex> FunFunc.Value.present?("")
false
iex> FunFunc.Value.present?(%{})
false
iex> FunFunc.Value.present?([])
false
iex> FunFunc.Value.present?(1)
true