mail v0.2.0 Mail.Proplist

A hybrid of erlang’s proplists and lists keystores.

It acts as a Set for key-value pairs, but stil maintains it’s order like a List.

Summary

Functions

Removes a key-value pair by the given key and returns the remaining list

Drops the specified keys from the list, returning the remaining

Filters the proplist, i.e. returns only those elements for which fun returns a truthy value

Retrieves a value from the list

Detects if the list contains the specified key

Retrieves all keys from the key value pairs present in the list, unlike :proplists.get_keys which will return non-kv pairs as keys

Concatentates the given lists

Merges duplicate pairs with the latest value

Prepends the key-value pair to the list if it doesn’t already exist, otherwise it will replace the existing pair

Stores a key-value pair in the list, will replace an existing pair with the same key

Takes the specified keys from the list, returning the remaining

Types

t :: [{term, term} | term]

Functions

delete(list, key)

Specs

delete(list :: Mail.Proplist.t, key :: term) :: Mail.Proplist.t

Removes a key-value pair by the given key and returns the remaining list

Args:

  • list - the list to remove the pair from
  • key - the key to remove
drop(list, keys)

Specs

drop(list :: Mail.Proplist.t, keys :: list) :: Mail.Proplist.t

Drops the specified keys from the list, returning the remaining.

Args:

  • list - the list
  • keys - the keys to remove
filter(list, func)

Specs

filter(list :: Mail.Proplist.t, func :: any) :: Mail.Proplist.t

Filters the proplist, i.e. returns only those elements for which fun returns a truthy value.

Args:

  • list - the list to filter
  • func - the function to execute
get(list, key)

Specs

get(list :: Mail.Proplist.t, key :: term) :: Mail.Proplist.t

Retrieves a value from the list

Args:

  • list - the list to look in
  • key - the key of the pair to retrieve it’s value
has_key?(list, key)

Specs

has_key?(list :: Mail.Proplist.t, key :: term) :: [term]

Detects if the list contains the specified key.

Args:

  • list - the list to look in
  • key - the key to look for
keys(list)

Specs

keys(list :: Mail.Proplist.t) :: [term]

Retrieves all keys from the key value pairs present in the list, unlike :proplists.get_keys which will return non-kv pairs as keys

Args:

  • list - a list to retrieve all the keys from
merge(a, b)

Specs

Concatentates the given lists.

Args:

  • a - base list to merge unto
  • b - list to merge with
normalize(list)

Specs

normalize(list :: Mail.Proplist.t) :: Mail.Proplist.t

Merges duplicate pairs with the latest value.

Args:

  • list - the list to normalize
prepend(list, key, value)

Specs

prepend(list :: Mail.Proplist.t, key :: term, value :: term) :: Mail.Proplist.t

Prepends the key-value pair to the list if it doesn’t already exist, otherwise it will replace the existing pair

Args:

  • list - the list to store in
  • key - the key of the pair
  • value - the value of the pair
put(list, key, value)

Specs

put(list :: Mail.Proplist.t, key :: term, value :: term) :: Mail.Proplist.t

Stores a key-value pair in the list, will replace an existing pair with the same key.

Args:

  • list - the list to store in
  • key - the key of the pair
  • value - the value of the pair
take(list, keys)

Specs

take(list :: Mail.Proplist.t, keys :: list) :: Mail.Proplist.t

Takes the specified keys from the list, returning the remaining.

Args:

  • list - the list
  • keys - the keys to keep