==1065334== Memcheck, a memory error detector ==1065334== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al. ==1065334== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info ==1065334== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R --vanilla --encoding=UTF-8 ==1065334== R Under development (unstable) (2026-01-30 r89357) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "automerge" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('automerge') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("am_apply_changes") > ### * am_apply_changes > > flush(stderr()); flush(stdout()) > > ### Name: am_apply_changes > ### Title: Apply changes to a document > ### Aliases: am_apply_changes > > ### ** Examples > > # Create two documents > doc1 <- am_create() > doc2 <- am_create() > > # Make changes in doc1 > am_put(doc1, AM_ROOT, "x", 1) > am_commit(doc1) > > # Get changes and apply to doc2 > changes <- am_get_changes(doc1, NULL) > am_apply_changes(doc2, changes) > > # Now doc2 has the same data as doc1 > > > > cleanEx() > nameEx("am_commit") > ### * am_commit > > flush(stderr()); flush(stdout()) > > ### Name: am_commit > ### Title: Commit pending changes > ### Aliases: am_commit > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "key", "value") > am_commit(doc, "Add initial data") > > # Commit with specific timestamp > am_commit(doc, "Update", Sys.time()) > > > > cleanEx() > nameEx("am_counter") > ### * am_counter > > flush(stderr()); flush(stdout()) > > ### Name: am_counter > ### Title: Create an Automerge counter > ### Aliases: am_counter > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "score", am_counter(0)) > > > > cleanEx() > nameEx("am_counter_increment") > ### * am_counter_increment > > flush(stderr()); flush(stdout()) > > ### Name: am_counter_increment > ### Title: Increment a counter value > ### Aliases: am_counter_increment > > ### ** Examples > > # Counter in document root (map) > doc <- am_create() > doc$score <- am_counter(0) > am_counter_increment(doc, AM_ROOT, "score", 10) > doc$score # 10 > > am_counter_increment(doc, AM_ROOT, "score", 5) > doc$score # 15 > > # Decrement with negative delta > am_counter_increment(doc, AM_ROOT, "score", -3) > doc$score # 12 > > # Counter in a nested map > doc$stats <- am_map(views = am_counter(0)) > stats_obj <- doc$stats > am_counter_increment(doc, stats_obj, "views", 100) > > # Counter in a list (1-based indexing) > doc$counters <- list(am_counter(0), am_counter(5)) > counters_obj <- doc$counters > am_counter_increment(doc, counters_obj, 1, 1) # Increment first counter > am_counter_increment(doc, counters_obj, 2, 2) # Increment second counter > > > > cleanEx() > nameEx("am_create") > ### * am_create > > flush(stderr()); flush(stdout()) > > ### Name: am_create > ### Title: Create a new Automerge document > ### Aliases: am_create > > ### ** Examples > > # Create document with random actor ID > doc <- am_create() > > # Create with custom hex actor ID > doc2 <- am_create("0123456789abcdef0123456789abcdef") > > # Create with raw bytes actor ID > actor_bytes <- as.raw(1:16) > doc3 <- am_create(actor_bytes) > > > > cleanEx() > nameEx("am_cursor") > ### * am_cursor > > flush(stderr()); flush(stdout()) > > ### Name: am_cursor > ### Title: Create a cursor at a position in a text object > ### Aliases: am_cursor > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "text", am_text("Hello World")) > text_obj <- am_get(doc, AM_ROOT, "text") > > # Create cursor at position 5 (after "Hello", before " ") > cursor <- am_cursor(text_obj, 5) > > # Modify text before cursor > am_text_splice(text_obj, 0, 0, "Hi ") > > # Cursor position automatically adjusts > new_pos <- am_cursor_position(cursor) > new_pos # 8 (cursor moved by 3 characters) [1] 8 > > > > cleanEx() > nameEx("am_cursor_position") > ### * am_cursor_position > > flush(stderr()); flush(stdout()) > > ### Name: am_cursor_position > ### Title: Get the current position of a cursor > ### Aliases: am_cursor_position > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "text", am_text("Hello World")) > text_obj <- am_get(doc, AM_ROOT, "text") > > # Create cursor > cursor <- am_cursor(text_obj, 5) > > # Get position > pos <- am_cursor_position(cursor) > pos # 5 [1] 5 > > > > cleanEx() > nameEx("am_delete") > ### * am_delete > > flush(stderr()); flush(stdout()) > > ### Name: am_delete > ### Title: Delete a key from a map or element from a list > ### Aliases: am_delete > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "temp", "value") > am_delete(doc, AM_ROOT, "temp") > > > > cleanEx() > nameEx("am_delete_path") > ### * am_delete_path > > flush(stderr()); flush(stdout()) > > ### Name: am_delete_path > ### Title: Delete value at path > ### Aliases: am_delete_path > > ### ** Examples > > doc <- am_create() > am_put_path(doc, c("user", "address", "city"), "NYC") > am_put_path(doc, c("user", "name"), "Alice") > > # Delete nested key > am_delete_path(doc, c("user", "address")) > > # Address should be gone > am_get_path(doc, c("user", "address")) # NULL NULL > > > > cleanEx() > nameEx("am_fork") > ### * am_fork > > flush(stderr()); flush(stdout()) > > ### Name: am_fork > ### Title: Fork an Automerge document > ### Aliases: am_fork > > ### ** Examples > > doc1 <- am_create() > doc2 <- am_fork(doc1) > > # Now doc1 and doc2 can diverge independently > > > > cleanEx() > nameEx("am_get") > ### * am_get > > flush(stderr()); flush(stdout()) > > ### Name: am_get > ### Title: Get a value from an Automerge map or list > ### Aliases: am_get > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "name", "Alice") > > name <- am_get(doc, AM_ROOT, "name") > name # "Alice" [1] "Alice" > > > > cleanEx() > nameEx("am_get_actor") > ### * am_get_actor > > flush(stderr()); flush(stdout()) > > ### Name: am_get_actor > ### Title: Get the actor ID of a document > ### Aliases: am_get_actor > > ### ** Examples > > doc <- am_create() > actor <- am_get_actor(doc) > > # Use am_get_actor_hex() for display > actor_hex <- am_get_actor_hex(doc) > cat("Actor ID:", actor_hex, "\n") Actor ID: fb4e953c2564b046e5caf6b779002a71 > > > > cleanEx() > nameEx("am_get_actor_hex") > ### * am_get_actor_hex > > flush(stderr()); flush(stdout()) > > ### Name: am_get_actor_hex > ### Title: Get the actor ID as a hex string > ### Aliases: am_get_actor_hex > > ### ** Examples > > doc <- am_create() > actor_hex <- am_get_actor_hex(doc) > cat("Actor ID:", actor_hex, "\n") Actor ID: a9351077a3ecd441236745356e733f67 > > > > cleanEx() > nameEx("am_get_change_by_hash") > ### * am_get_change_by_hash > > flush(stderr()); flush(stdout()) > > ### Name: am_get_change_by_hash > ### Title: Get a specific change by its hash > ### Aliases: am_get_change_by_hash > > ### ** Examples > > doc <- am_create() > doc$key <- "value" > am_commit(doc, "Add key") > > # Get the current heads (change hashes) > heads <- am_get_heads(doc) > head_hash <- heads[[1]] > > # Retrieve the change by its hash > change <- am_get_change_by_hash(doc, head_hash) > str(change) # Raw vector raw [1:70] 85 6f 4a 83 ... > > > > cleanEx() > nameEx("am_get_changes") > ### * am_get_changes > > flush(stderr()); flush(stdout()) > > ### Name: am_get_changes > ### Title: Get changes since specified heads > ### Aliases: am_get_changes > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "x", 1) > am_commit(doc) > > # Get all changes > all_changes <- am_get_changes(doc, NULL) > cat("Document has", length(all_changes), "change(s)\n") Document has 1 change(s) > > > > cleanEx() > nameEx("am_get_changes_added") > ### * am_get_changes_added > > flush(stderr()); flush(stdout()) > > ### Name: am_get_changes_added > ### Title: Get changes in one document that are not in another > ### Aliases: am_get_changes_added > > ### ** Examples > > # Create two independent documents > doc1 <- am_create() > doc1$x <- 1 > am_commit(doc1, "Add x") > > doc2 <- am_create() > doc2$y <- 2 > am_commit(doc2, "Add y") > > # Find changes in doc2 that aren't in doc1 > changes <- am_get_changes_added(doc1, doc2) > length(changes) # 1 change [1] 1 > > # Apply those changes to doc1 > am_apply_changes(doc1, changes) ==1065334== Conditional jump or move depends on uninitialised value(s) ==1065334== at 0x178EEA66: automerge::patches::patch_log::PatchLog::migrate_actors (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x1786FEAE: automerge::op_set2::change::batch::BatchApply::apply (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x179399E6: automerge::automerge::Automerge::apply_changes_log_patches (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x1793B7A4: automerge::automerge::Automerge::load_incremental_log_patches (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x177EF296: AMloadIncremental (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x177B38D3: C_am_apply_changes (packages/tests-vg/automerge/src/sync.c:299) ==1065334== by 0x4A7E29: R_doDotCall (svn/R-devel/src/main/dotcode.c:757) ==1065334== by 0x4E1E83: bcEval_loop (svn/R-devel/src/main/eval.c:8682) ==1065334== by 0x4F1FD7: bcEval (svn/R-devel/src/main/eval.c:7515) ==1065334== by 0x4F1FD7: bcEval (svn/R-devel/src/main/eval.c:7500) ==1065334== by 0x4F230A: Rf_eval (svn/R-devel/src/main/eval.c:1167) ==1065334== by 0x4F408D: R_execClosure (svn/R-devel/src/main/eval.c:2389) ==1065334== by 0x4F4D46: applyClosure_core (svn/R-devel/src/main/eval.c:2302) ==1065334== Uninitialised value was created by a stack allocation ==1065334== at 0x178EDB7A: automerge::patches::patch_log::PatchLog::migrate_actors (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== > > # Now doc1 has both x and y > names(doc1) # "x" "y" [1] "x" "y" > > > > cleanEx() > nameEx("am_get_heads") > ### * am_get_heads > > flush(stderr()); flush(stdout()) > > ### Name: am_get_heads > ### Title: Get the current heads of a document > ### Aliases: am_get_heads > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "x", 1) > am_commit(doc) > > heads <- am_get_heads(doc) > cat("Document has", length(heads), "head(s)\n") Document has 1 head(s) > > > > cleanEx() > nameEx("am_get_history") > ### * am_get_history > > flush(stderr()); flush(stdout()) > > ### Name: am_get_history > ### Title: Get document history > ### Aliases: am_get_history > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "x", 1) > am_commit(doc, "Initial") > am_put(doc, AM_ROOT, "x", 2) > am_commit(doc, "Update") > > history <- am_get_history(doc) > cat("Document history contains", length(history), "change(s)\n") Document history contains 2 change(s) > > > > cleanEx() > nameEx("am_get_last_local_change") > ### * am_get_last_local_change > > flush(stderr()); flush(stdout()) > > ### Name: am_get_last_local_change > ### Title: Get the last change made by the local actor > ### Aliases: am_get_last_local_change > > ### ** Examples > > doc <- am_create() > > # Initially, no local changes > am_get_last_local_change(doc) # NULL NULL > > # Make a change > doc$key <- "value" > am_commit(doc, "Add key") > > # Now we have a local change > change <- am_get_last_local_change(doc) > str(change) # Raw vector raw [1:70] 85 6f 4a 83 ... > > > > cleanEx() > nameEx("am_get_path") > ### * am_get_path > > flush(stderr()); flush(stdout()) > > ### Name: am_get_path > ### Title: Navigate deep structures with path > ### Aliases: am_get_path > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "user", list( + name = "Alice", + address = list(city = "NYC", zip = 10001L) + )) > > # Navigate to nested value > am_get_path(doc, c("user", "address", "city")) # "NYC" [1] "NYC" > > # Mixed navigation (map key, then list index) > doc$users <- list( + list(name = "Bob"), + list(name = "Carol") + ) > am_get_path(doc, list("users", 1, "name")) # "Bob" [1] "Bob" > > > > cleanEx() > nameEx("am_insert") > ### * am_insert > > flush(stderr()); flush(stdout()) > > ### Name: am_insert > ### Title: Insert a value into an Automerge list > ### Aliases: am_insert > > ### ** Examples > > doc <- am_create() > # Create a list and get it > am_put(doc, AM_ROOT, "items", AM_OBJ_TYPE_LIST) > items <- am_get(doc, AM_ROOT, "items") > > # Insert items > am_insert(doc, items, "end", "first") > am_insert(doc, items, "end", "second") > > > > cleanEx() > nameEx("am_keys") > ### * am_keys > > flush(stderr()); flush(stdout()) > > ### Name: am_keys > ### Title: Get all keys from an Automerge map > ### Aliases: am_keys > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "a", 1) > am_put(doc, AM_ROOT, "b", 2) > > keys <- am_keys(doc, AM_ROOT) > keys # c("a", "b") [1] "a" "b" > > > > cleanEx() > nameEx("am_length") > ### * am_length > > flush(stderr()); flush(stdout()) > > ### Name: am_length > ### Title: Get the length of an Automerge map or list > ### Aliases: am_length > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "a", 1) > am_put(doc, AM_ROOT, "b", 2) > > len <- am_length(doc, AM_ROOT) > len # 2 [1] 2 > > > > cleanEx() > nameEx("am_list") > ### * am_list > > flush(stderr()); flush(stdout()) > > ### Name: am_list > ### Title: Create an Automerge list > ### Aliases: am_list > > ### ** Examples > > # Empty list (avoids ambiguity) > am_list() list() attr(,"class") [1] "am_list_type" "list" > > # Populated list > am_list("a", "b", "c") [[1]] [1] "a" [[2]] [1] "b" [[3]] [1] "c" attr(,"class") [1] "am_list_type" "list" > > > > cleanEx() > nameEx("am_load") > ### * am_load > > flush(stderr()); flush(stdout()) > > ### Name: am_load > ### Title: Load an Automerge document from binary format > ### Aliases: am_load > > ### ** Examples > > # Create, save, and reload > doc1 <- am_create() > bytes <- am_save(doc1) > doc2 <- am_load(bytes) > > # Save to and load from file > file <- tempfile() > writeBin(am_save(doc1), file) > > doc <- am_load(readBin(file, "raw", 1e5)) > unlink(file) > > > > cleanEx() > nameEx("am_map") > ### * am_map > > flush(stderr()); flush(stdout()) > > ### Name: am_map > ### Title: Create an Automerge map > ### Aliases: am_map > > ### ** Examples > > # Empty map (avoids ambiguity) > am_map() list() attr(,"class") [1] "am_map_type" "list" > > # Populated map > am_map(key1 = "value1", key2 = "value2") $key1 [1] "value1" $key2 [1] "value2" attr(,"class") [1] "am_map_type" "list" > > > > cleanEx() > nameEx("am_mark") > ### * am_mark > > flush(stderr()); flush(stdout()) > > ### Name: am_mark > ### Title: Create a mark on a text range > ### Aliases: am_mark > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "text", am_text("Hello World")) > text_obj <- am_get(doc, AM_ROOT, "text") > > # Mark "Hello" as bold (positions 0-4, characters 0-4) > am_mark(text_obj, 0, 5, "bold", TRUE) > > # Mark "World" as italic with expansion > am_mark(text_obj, 6, 11, "italic", TRUE, + expand = AM_MARK_EXPAND_BOTH) > > # Get all marks > marks <- am_marks(text_obj) > marks [[1]] [[1]]$name [1] "bold" [[1]]$value [1] TRUE [[1]]$start [1] 0 [[1]]$end [1] 5 [[2]] [[2]]$name [1] "italic" [[2]]$value [1] TRUE [[2]]$start [1] 6 [[2]]$end [1] 11 > > > > cleanEx() > nameEx("am_marks") > ### * am_marks > > flush(stderr()); flush(stdout()) > > ### Name: am_marks > ### Title: Get all marks in a text object > ### Aliases: am_marks > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "text", am_text("Hello World")) > text_obj <- am_get(doc, AM_ROOT, "text") > > am_mark(text_obj, 0, 5, "bold", TRUE) > am_mark(text_obj, 6, 11, "italic", TRUE) > > marks <- am_marks(text_obj) > marks [[1]] [[1]]$name [1] "bold" [[1]]$value [1] TRUE [[1]]$start [1] 0 [[1]]$end [1] 5 [[2]] [[2]]$name [1] "italic" [[2]]$value [1] TRUE [[2]]$start [1] 6 [[2]]$end [1] 11 > # List of 2 marks with name, value, start, end > > > > cleanEx() > nameEx("am_marks_at") > ### * am_marks_at > > flush(stderr()); flush(stdout()) > > ### Name: am_marks_at > ### Title: Get marks at a specific position > ### Aliases: am_marks_at > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "text", am_text("Hello World")) > text_obj <- am_get(doc, AM_ROOT, "text") > > am_mark(text_obj, 0, 5, "bold", TRUE) > am_mark(text_obj, 2, 7, "underline", TRUE) > > # Get marks at position 3 (inside "Hello") > marks_at_3 <- am_marks_at(text_obj, 3) > marks_at_3 [[1]] [[1]]$name [1] "bold" [[1]]$value [1] TRUE [[1]]$start [1] 0 [[1]]$end [1] 5 [[2]] [[2]]$name [1] "underline" [[2]]$value [1] TRUE [[2]]$start [1] 2 [[2]]$end [1] 7 > # List of 2 marks (both "bold" and "underline" include position 3) > > > > cleanEx() > nameEx("am_merge") > ### * am_merge > > flush(stderr()); flush(stdout()) > > ### Name: am_merge > ### Title: Merge changes from another document > ### Aliases: am_merge > > ### ** Examples > > doc1 <- am_create() > doc2 <- am_create() > > # Make changes in each document > am_put(doc1, AM_ROOT, "x", 1) > am_put(doc2, AM_ROOT, "y", 2) > > # Merge doc2's changes into doc1 > am_merge(doc1, doc2) ==1065334== Conditional jump or move depends on uninitialised value(s) ==1065334== at 0x178EEA66: automerge::patches::patch_log::PatchLog::migrate_actors (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x1786FEAE: automerge::op_set2::change::batch::BatchApply::apply (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x179399E6: automerge::automerge::Automerge::apply_changes_log_patches (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x1793BC09: automerge::automerge::Automerge::merge_and_log_patches (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x177EF50F: AMmerge (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== by 0x177B0244: C_am_merge (packages/tests-vg/automerge/src/document.c:272) ==1065334== by 0x4A7E29: R_doDotCall (svn/R-devel/src/main/dotcode.c:757) ==1065334== by 0x4E1E83: bcEval_loop (svn/R-devel/src/main/eval.c:8682) ==1065334== by 0x4F1FD7: bcEval (svn/R-devel/src/main/eval.c:7515) ==1065334== by 0x4F1FD7: bcEval (svn/R-devel/src/main/eval.c:7500) ==1065334== by 0x4F230A: Rf_eval (svn/R-devel/src/main/eval.c:1167) ==1065334== by 0x4F408D: R_execClosure (svn/R-devel/src/main/eval.c:2389) ==1065334== by 0x4F4D46: applyClosure_core (svn/R-devel/src/main/eval.c:2302) ==1065334== Uninitialised value was created by a stack allocation ==1065334== at 0x178EDB7A: automerge::patches::patch_log::PatchLog::migrate_actors (in /data/blackswan/ripley/R/packages/tests-vg/automerge.Rcheck/automerge/libs/automerge.so) ==1065334== > # Now doc1 has both x and y > > > > cleanEx() > nameEx("am_put") > ### * am_put > > flush(stderr()); flush(stdout()) > > ### Name: am_put > ### Title: Put a value into an Automerge map or list > ### Aliases: am_put > > ### ** Examples > > doc <- am_create() > > # Put values in root map (returns doc invisibly) > am_put(doc, AM_ROOT, "name", "Alice") > am_put(doc, AM_ROOT, "age", 30L) > am_put(doc, AM_ROOT, "active", TRUE) > > # Create nested list and retrieve it > am_put(doc, AM_ROOT, "items", AM_OBJ_TYPE_LIST) > items <- am_get(doc, AM_ROOT, "items") > > > > cleanEx() > nameEx("am_put_path") > ### * am_put_path > > flush(stderr()); flush(stdout()) > > ### Name: am_put_path > ### Title: Set value at path > ### Aliases: am_put_path > > ### ** Examples > > doc <- am_create() > > # Create nested structure with automatic intermediate objects > am_put_path(doc, c("user", "address", "city"), "Boston") > am_put_path(doc, c("user", "address", "zip"), 02101L) > am_put_path(doc, c("user", "name"), "Alice") > > # Verify > am_get_path(doc, c("user", "address", "city")) # "Boston" [1] "Boston" > > > > cleanEx() > nameEx("am_rollback") > ### * am_rollback > > flush(stderr()); flush(stdout()) > > ### Name: am_rollback > ### Title: Roll back pending operations > ### Aliases: am_rollback > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "key", "value") > # Changed my mind, discard the put > am_rollback(doc) > > > > cleanEx() > nameEx("am_save") > ### * am_save > > flush(stderr()); flush(stdout()) > > ### Name: am_save > ### Title: Save an Automerge document to binary format > ### Aliases: am_save > > ### ** Examples > > doc <- am_create() > bytes <- am_save(doc) > > # Save to file > file <- tempfile() > writeBin(am_save(doc), file) > unlink(file) > > > > cleanEx() > nameEx("am_set_actor") > ### * am_set_actor > > flush(stderr()); flush(stdout()) > > ### Name: am_set_actor > ### Title: Set the actor ID of a document > ### Aliases: am_set_actor > > ### ** Examples > > doc <- am_create() > > # Set custom actor ID from hex string > am_set_actor(doc, "0123456789abcdef0123456789abcdef") > > # Generate new random actor ID > am_set_actor(doc, NULL) > > > > cleanEx() > nameEx("am_sync") > ### * am_sync > > flush(stderr()); flush(stdout()) > > ### Name: am_sync > ### Title: Bidirectional synchronization > ### Aliases: am_sync > > ### ** Examples > > # Create two documents with different changes > doc1 <- am_create() > doc2 <- am_create() > > # Make changes in each document > am_put(doc1, AM_ROOT, "x", 1) > am_put(doc2, AM_ROOT, "y", 2) > > # Synchronize them (documents modified in place) > rounds <- am_sync(doc1, doc2) > cat("Synced in", rounds, "rounds\n") Synced in 4 rounds > > # Now both documents have both x and y > > > > cleanEx() > nameEx("am_sync_decode") > ### * am_sync_decode > > flush(stderr()); flush(stdout()) > > ### Name: am_sync_decode > ### Title: Receive and apply a sync message > ### Aliases: am_sync_decode > > ### ** Examples > > doc <- am_create() > sync_state <- am_sync_state_new() > > # Receive message from peer > # message <- ... (received from network) > # am_sync_decode(doc, sync_state, message) > > > > cleanEx() > nameEx("am_sync_encode") > ### * am_sync_encode > > flush(stderr()); flush(stdout()) > > ### Name: am_sync_encode > ### Title: Generate a sync message > ### Aliases: am_sync_encode > > ### ** Examples > > doc <- am_create() > sync_state <- am_sync_state_new() > > # Generate first sync message > msg <- am_sync_encode(doc, sync_state) > if (!is.null(msg)) { + # Send msg to peer... + } NULL > > > > cleanEx() > nameEx("am_sync_state_new") > ### * am_sync_state_new > > flush(stderr()); flush(stdout()) > > ### Name: am_sync_state_new > ### Title: Create a new sync state > ### Aliases: am_sync_state_new > > ### ** Examples > > # Create two documents > doc1 <- am_create() > doc2 <- am_create() > > # Create sync states for each peer > sync1 <- am_sync_state_new() > sync2 <- am_sync_state_new() > > # Use with am_sync_encode() and am_sync_decode() > > > > cleanEx() > nameEx("am_text") > ### * am_text > > flush(stderr()); flush(stdout()) > > ### Name: am_text > ### Title: Create an Automerge text object > ### Aliases: am_text > > ### ** Examples > > # Empty text object > am_text() [1] "" attr(,"class") [1] "am_text_type" "character" > > # Text with initial content > am_text("Hello, World!") [1] "Hello, World!" attr(,"class") [1] "am_text_type" "character" > > > > cleanEx() > nameEx("am_text_content") > ### * am_text_content > > flush(stderr()); flush(stdout()) > > ### Name: am_text_content > ### Title: Get text content from a text object > ### Aliases: am_text_content > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "doc", am_text("Hello")) > text_obj <- am_get(doc, AM_ROOT, "doc") > > text <- am_text_content(text_obj) > text # "Hello" [1] "Hello" > > > > cleanEx() > nameEx("am_text_splice") > ### * am_text_splice > > flush(stderr()); flush(stdout()) > > ### Name: am_text_splice > ### Title: Splice text in a text object > ### Aliases: am_text_splice > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "doc", am_text("Hello")) > text_obj <- am_get(doc, AM_ROOT, "doc") > > # Insert " World" at position 5 (after "Hello") > am_text_splice(text_obj, 5, 0, " World") > > # Get the full text > am_text_content(text_obj) # "Hello World" [1] "Hello World" > > # Works naturally with multibyte characters > am_put(doc, AM_ROOT, "greet", am_text("")) > text_obj2 <- am_get(doc, AM_ROOT, "greet") > am_text_splice(text_obj2, 0, 0, "Column café") > # Position 11 is after "café" (character index, not bytes) > am_text_splice(text_obj2, 11, 0, "!") > am_text_content(text_obj2) # "Column café!" [1] "Column café!" > > > > cleanEx() > nameEx("am_text_update") > ### * am_text_update > > flush(stderr()); flush(stdout()) > > ### Name: am_text_update > ### Title: Update text content > ### Aliases: am_text_update > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "content", am_text("Hello")) > text_obj <- am_get(doc, AM_ROOT, "content") > > # Efficiently update text by computing and applying diff in one step > am_text_update(text_obj, "Hello", "Hello World") > am_text_content(text_obj) # "Hello World" [1] "Hello World" > > # Works with Unicode > am_text_update(text_obj, "Hello World", "Hello World!") > am_text_content(text_obj) # "Hello World!" [1] "Hello World!" > > > > cleanEx() > nameEx("am_uint64") > ### * am_uint64 > > flush(stderr()); flush(stdout()) > > ### Name: am_uint64 > ### Title: Create an unsigned 64-bit integer value > ### Aliases: am_uint64 > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "id", am_uint64(12345)) > > > > cleanEx() > nameEx("am_values") > ### * am_values > > flush(stderr()); flush(stdout()) > > ### Name: am_values > ### Title: Get all values from a map or list > ### Aliases: am_values > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "a", 1) > am_put(doc, AM_ROOT, "b", 2) > am_put(doc, AM_ROOT, "c", 3) > > values <- am_values(doc, AM_ROOT) > values # list(1, 2, 3) [[1]] [1] 1 [[2]] [1] 2 [[3]] [1] 3 > > > > cleanEx() > nameEx("as.character.am_text") > ### * as.character.am_text > > flush(stderr()); flush(stdout()) > > ### Name: as.character.am_text > ### Title: Convert text object to character string > ### Aliases: as.character.am_text > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "notes", am_text("Hello World")) > text_obj <- am_get(doc, AM_ROOT, "notes") > > text_string <- as.character(text_obj) > text_string # "Hello World" [1] "Hello World" > > identical(as.character(text_obj), am_text_content(text_obj)) # TRUE [1] TRUE > > > > cleanEx() > nameEx("as.list.am_doc") > ### * as.list.am_doc > > flush(stderr()); flush(stdout()) > > ### Name: as.list.am_doc > ### Title: Convert document root to R list > ### Aliases: as.list.am_doc > > ### ** Examples > > doc <- am_create() > doc$name <- "Alice" > doc$age <- 30L > > as.list(doc) # list(name = "Alice", age = 30L) $age [1] 30 $name [1] "Alice" > > > > cleanEx() > nameEx("as_automerge") > ### * as_automerge > > flush(stderr()); flush(stdout()) > > ### Name: as_automerge > ### Title: Convert R list to Automerge document > ### Aliases: as_automerge > > ### ** Examples > > # Convert nested list to Automerge > data <- list( + name = "Alice", + age = 30L, + scores = list(85, 90, 95), + metadata = list( + created = Sys.time(), + tags = list("user", "active") + ) + ) > > doc <- as_automerge(data) > doc[["name"]] # "Alice" [1] "Alice" > doc[["age"]] # 30L [1] 30 > > > > cleanEx() > nameEx("extract-am_doc") > ### * extract-am_doc > > flush(stderr()); flush(stdout()) > > ### Name: extract-am_doc > ### Title: Extract from Automerge document root > ### Aliases: extract-am_doc [[.am_doc $.am_doc > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "name", "Alice") > am_put(doc, AM_ROOT, "age", 30L) > > doc[["name"]] # "Alice" [1] "Alice" > doc$age # 30L [1] 30 > > > > cleanEx() > nameEx("extract-am_object") > ### * extract-am_object > > flush(stderr()); flush(stdout()) > > ### Name: extract-am_object > ### Title: Extract from Automerge object > ### Aliases: extract-am_object [[.am_object $.am_object > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "user", list(name = "Bob", age = 25L)) > user <- am_get(doc, AM_ROOT, "user") > > user[["name"]] # "Bob" [1] "Bob" > user$age # 25L [1] 25 > > > > cleanEx() > nameEx("from_automerge") > ### * from_automerge > > flush(stderr()); flush(stdout()) > > ### Name: from_automerge > ### Title: Convert Automerge document to R list > ### Aliases: from_automerge > > ### ** Examples > > doc <- am_create() > doc$name <- "Alice" > doc$age <- 30L > > from_automerge(doc) # list(name = "Alice", age = 30L) $age [1] 30 $name [1] "Alice" > > > > cleanEx() > nameEx("length.am_doc") > ### * length.am_doc > > flush(stderr()); flush(stdout()) > > ### Name: length.am_doc > ### Title: Get length of document root > ### Aliases: length.am_doc > > ### ** Examples > > doc <- am_create() > doc$a <- 1 > doc$b <- 2 > length(doc) # 2 [1] 2 > > > > cleanEx() > nameEx("names.am_doc") > ### * names.am_doc > > flush(stderr()); flush(stdout()) > > ### Name: names.am_doc > ### Title: Get names from document root > ### Aliases: names.am_doc > > ### ** Examples > > doc <- am_create() > doc$name <- "Alice" > doc$age <- 30L > names(doc) # c("name", "age") [1] "age" "name" > > > > cleanEx() > nameEx("replace-am_doc") > ### * replace-am_doc > > flush(stderr()); flush(stdout()) > > ### Name: replace-am_doc > ### Title: Replace in Automerge document root > ### Aliases: replace-am_doc [[<-.am_doc $<-.am_doc > > ### ** Examples > > doc <- am_create() > doc[["name"]] <- "Bob" > doc$age <- 25L > > > > cleanEx() > nameEx("replace-am_object") > ### * replace-am_object > > flush(stderr()); flush(stdout()) > > ### Name: replace-am_object > ### Title: Replace in Automerge object > ### Aliases: replace-am_object [[<-.am_object $<-.am_object > > ### ** Examples > > doc <- am_create() > am_put(doc, AM_ROOT, "user", list(name = "Bob", age = 25L)) > user <- am_get(doc, AM_ROOT, "user") > > user[["name"]] <- "Alice" > user$age <- 30L > > > > ### *