Skip to content

Returns detailed information about each entry in a map or list, including the key (or index) and value for each item. This provides more information than am_values() alone.

Usage

am_items(doc, obj, heads = NULL)

Arguments

doc

An Automerge document

obj

An Automerge object ID (from nested object), or AM_ROOT for the document root

heads

Optional list of change hashes (raw vectors) for historical query. If NULL (default), uses the current state.

Value

A list of lists, where each inner list has fields:

key

For maps: the character key. For lists: the 1-based integer index.

value

The value at this entry.

Note

When called on a text object, this iterates individual characters as list items. Use am_text_content() to retrieve text as a string instead.

Examples

doc <- am_create()
doc$name <- "Alice"
doc$age <- 30L

items <- am_items(doc, AM_ROOT)
items[[1]]$key    # "age" (sorted lexicographically)
#> [1] "age"
items[[1]]$value  # 30
#> [1] 30

am_close(doc)