-
-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Description
When working with LoroTree, the API uses node.data to access the node's LoroMap, but toJSON() outputs this as meta:
Example
import { LoroDoc } from "loro-crdt"
const doc = new LoroDoc()
const tree = doc.getTree("tree")
// Create a node
const node = tree.createNode()
// The API uses `.data` to access the node's LoroMap
node.data.set("name", "root")
node.data.set("value", 42)
console.log("API uses .data:", node.data.toJSON())
// Output: { name: "root", value: 42 }
// But toJSON() outputs it as `meta`
console.log("toJSON uses meta:", JSON.stringify(tree.toJSON(), null, 2))Output:
[
{
parent: null,
index: 0,
meta: { name: 'root', value: 42 }, <-- "meta" instead of "data"
id: '0@3781444021239823132',
fractional_index: '80',
children: []
}
]
I think it would be more consistent if the toJSON() output also used data as the key here.
Metadata
Metadata
Assignees
Labels
No labels