View Source Surface.Catalogue.Data (surface v0.11.5)
Experimental module that provides conveniences for manipulating data in Examples and Playgrounds.
Provide wrappers around built-in functions like get_in/2
and update_in/3
using a shorter syntax for accessors.
Accessor Mapping
[_]
:Access.all/0
[fun]
:Access.filter(fun)
[index]
:Access.at(index)
(Shorthand for[index: i]
)[index: i]
:Access.at(i)
[key: k]
:Access.key(k)
[first..last]
:Surface.Catalogue.Data.slice(first..last)
Example
Data.get(props.lists[_].cards[& &1.id == "Card_1"].tags[-1].name)
The code above will be translated to:
get_in(props, [:lists, Access.all, :cards, Access.filter(& &1.id == "Card_1"), :tags, Access.at(-1), :name])
Summary
Functions
Appends an item to a list in the given nested structure.
Deletes an item from the given nested structure.
Gets a value from the given nested structure.
Gets an existing value from the given nested structure.
Gets a value and updates a given nested structure.
Inserts an item into a list in the given nested structure.
Pops a item from the given nested structure.
Prepends an item to a list in the given nested structure.
Generates a short ramdom id.
Updates an item in the given nested structure.
Functions
Appends an item to a list in the given nested structure.
Deletes an item from the given nested structure.
Gets a value from the given nested structure.
A wrapper around get_in/2
Gets an existing value from the given nested structure.
Raises an error if none or more than one value is found.
Gets a value and updates a given nested structure.
A wrapper around get_and_update_in/3
Inserts an item into a list in the given nested structure.
Pops a item from the given nested structure.
A wrapper around pop_in/2
Prepends an item to a list in the given nested structure.
Generates a short ramdom id.
Updates an item in the given nested structure.
A wrapper around update_in/2