Yex.MapPrelim (y_ex v0.8.0)

View Source

A preliminary map representation used for initializing map content. This module provides functionality for creating map content before it is inserted into a shared document.

Use Cases

  • Creating map content before inserting into a document
  • Serializing map content for transfer between documents
  • Initializing map content with specific key-value pairs
  • Preparing nested data structures for shared documents

Examples

iex> doc = Yex.Doc.new()
iex> array = Yex.Doc.get_array(doc, "array")
iex> Yex.Array.insert(array, 0, Yex.MapPrelim.from(%{ "key" => "value" }))
iex> {:ok, %Yex.Map{} = map} = Yex.Array.fetch(array, 0)
iex> Yex.Map.fetch(map, "key")
{:ok, "value"}

Summary

Functions

Creates a new MapPrelim from an Elixir map. This is useful when you want to initialize a shared map with predefined content.

Types

t()

@type t() :: %Yex.MapPrelim{map: map()}

Functions

from(map)

Creates a new MapPrelim from an Elixir map. This is useful when you want to initialize a shared map with predefined content.

Parameters

  • map - An Elixir map to convert to a preliminary map

Examples

iex> prelim = Yex.MapPrelim.from(%{"key" => "value", "nested" => %{"inner" => "data"}})
iex> doc = Yex.Doc.new()
iex> map = Yex.Doc.get_map(doc, "map")
iex> Yex.Map.set(map, "content", prelim)