View Source MyspaceIPFS.Utils (Myspace IPFS v0.1.0-alpha.1)

Some common functions that are used throughout the library.

Link to this section Summary

Functions

Filter out any empty values from a list. Removes nil, {}, [], and "".

Extracts the data from a response. Given a response, it will structure the data in a way that is easier to work with. IPFS only sends strings. This function will convert the string to a list of maps.

Wraps the data in an elixir standard response tuple. {:ok, data} or {:error, data}

Unlists a list if it only contains one element.

Link to this section Functions

@spec filter_empties(list()) :: list()

Filter out any empty values from a list. Removes nil, {}, [], and "".

Link to this function

map_response_data(response)

View Source
@spec map_response_data(any()) :: list()

Extracts the data from a response. Given a response, it will structure the data in a way that is easier to work with. IPFS only sends strings. This function will convert the string to a list of maps.

@spec okify(any()) :: {:ok, any()} | {:error, any()}

Wraps the data in an elixir standard response tuple. {:ok, data} or {:error, data}

@spec unlist(list()) :: any()

Unlists a list if it only contains one element.