Dowser.CoreExt.Keyable protocol (Dowser.Client v0.3.0)

View Source

Applies a function to every key of a term, however deeply nested — through maps, lists and MapSets; any other term passes through unchanged.

Dowser.Client.Decoder is the pass dowser_client runs itself from :keys/:decoder; this protocol casts a whole term's keys in one go, for a backend package that needs to do it on its own:

Dowser.CoreExt.Keyable.transform_keys(body, &String.to_existing_atom/1)

String.to_atom/1 grows the atom table for every key a backend ever returns, so prefer String.to_existing_atom/1 on anything attacker- or mapping-driven.

Summary

Types

t()

All the types that implement this protocol.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

transform_keys(value, key_fn)

@spec transform_keys(term(), (String.t() -> term())) :: term()