View Source Igniter.Code.Keyword (igniter v0.3.4)

Utilities for working with keyword.

Summary

Functions

Returns true if the node is a nested keyword list containing a value at the given path.

Returns true if the node is a nested keyword list containing a value at the given path.

Puts into nested keyword lists represented by path

Puts a value at a path into a keyword, calling updater on the zipper at the value if the key is already present

Removes a key from a keyword list if present. Returns :error only if the node is not a list

Functions

@spec get_key(Sourceror.Zipper.t(), atom()) :: term()

Returns true if the node is a nested keyword list containing a value at the given path.

Link to this function

keyword_has_path?(zipper, list)

View Source
@spec keyword_has_path?(Sourceror.Zipper.t(), [atom()]) :: boolean()

Returns true if the node is a nested keyword list containing a value at the given path.

@spec keywordify(path :: [atom()], value :: any()) :: any()

Puts into nested keyword lists represented by path

Link to this function

put_in_keyword(zipper, path, value, updater \\ nil)

View Source
@spec put_in_keyword(
  Sourceror.Zipper.t(),
  [atom()],
  term(),
  (Sourceror.Zipper.t() -> {:ok, Sourceror.Zipper.t()} | :error) | nil
) :: {:ok, Sourceror.Zipper.t()} | :error

Puts a value at a path into a keyword, calling updater on the zipper at the value if the key is already present

Link to this function

remove_keyword_key(zipper, key)

View Source
@spec remove_keyword_key(Sourceror.Zipper.t(), atom()) ::
  {:ok, Sourceror.Zipper.t()} | :error

Removes a key from a keyword list if present. Returns :error only if the node is not a list

Link to this function

set_keyword_key(zipper, key, value, updater)

View Source
@spec set_keyword_key(
  Sourceror.Zipper.t(),
  atom(),
  term(),
  (Sourceror.Zipper.t() -> {:ok, Sourceror.Zipper.t()} | :error)
) :: {:ok, Sourceror.Zipper.t()} | :error