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 truthy?/1

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

Link to this function blank?(x)
blank?(any()) :: boolean()

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
Link to this function empty?(x)
empty?(any()) :: boolean()

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
Link to this function falsy?(x)
falsy?(any()) :: boolean()

The opposite of truthy?/1.

Examples

iex> FunFunc.Value.falsy?(1)
false
iex> FunFunc.Value.falsy?(false)
true
iex> FunFunc.Value.falsy?(nil)
true
Link to this function non_empty?(x)
non_empty?(any()) :: boolean()

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

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
Link to this function present?(x)
present?(any()) :: boolean()

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
Link to this function truthy?(x)
truthy?(any()) :: boolean()

Returns true if not false nor nil.

Examples

iex> FunFunc.Value.truthy?(1)
true
iex> FunFunc.Value.truthy?(false)
false
iex> FunFunc.Value.truthy?(nil)
false