Published
Edited
Apr 8, 2020
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
u = requires("unist-builder")
Insert cell
visit = requires("unist-util-visit")
Insert cell
{
const tree = u("root", [
u("subtree", { id: 1 }),
u("subtree", { id: 2 }, [
u("node", [u("leaf", "leaf 1"), u("leaf", "leaf 2")]),
u("leaf", { id: 3 }, "leaf 3"),
u("void", { id: 4 })
])
])

return tree
}
Insert cell
{
const tree = u("tree", [
u("leaf", "1"),
u("node", [u("leaf", "2")]),
u("void"),
u("leaf", "3")
])

const nodes = []
visit(tree, "leaf", node => {
nodes.push(node)
})
return nodes
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more