# `Igniter.Code.Keyword`
[🔗](https://github.com/ash-project/igniter/blob/v0.8.3/lib/igniter/code/keyword.ex#L5)

Utilities for working with keyword.

# `get_key`

```elixir
@spec get_key(Sourceror.Zipper.t(), atom()) :: {:ok, Sourceror.Zipper.t()} | :error
```

Moves the zipper to the value of `key` in a keyword list.

# `keyword_has_path?`

```elixir
@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.

# `keywordify`

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

Puts into nested keyword lists represented by `path`

# `put_in_keyword`

```elixir
@spec put_in_keyword(
  Sourceror.Zipper.t(),
  [atom()],
  term(),
  (Sourceror.Zipper.t() -&gt;
     {:ok, Sourceror.Zipper.t()}
     | :error
     | {:error, String.t()}
     | {:warning, String.t()})
  | nil
) ::
  {:ok, Sourceror.Zipper.t()}
  | :error
  | {:error, String.t()}
  | {:warning, String.t()}
```

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

Navigates through nested keyword lists following the given `path` (list of atoms).
If the full path doesn't exist, it creates the necessary nested structure.
If the path exists, it calls the `updater` function with the zipper at the existing value.

The `updater` function can return:
- `{:ok, zipper}` - Replace the existing value with the updated zipper
- anything else, which is returned untouched

This function preserves any errors or warnings returned by the updater function,
passing them through unchanged.

# `remove_keyword_key`

```elixir
@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

# `set_keyword_key`

```elixir
@spec set_keyword_key(
  Sourceror.Zipper.t(),
  atom(),
  term(),
  (Sourceror.Zipper.t() -&gt; {:ok, Sourceror.Zipper.t()} | term()) | nil
) :: {:ok, Sourceror.Zipper.t()} | term()
```

Sets a key in a keyword list to a value.

If the key already exists, calls the `updater` function with the zipper at the existing value.
If the key doesn't exist, sets it to the given `value`.

The `updater` function can return:
- `{:ok, zipper}` - Replace the existing value with the updated zipper
- anything else - which is returned untouched

This function preserves any errors or warnings returned by the updater function,
passing them through unchanged.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
