MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / expandObj

Function expandObj

src/client/sandbox.mjs:594–614  ·  view source on GitHub ↗
(node, type, val)

Source from the content-addressed store, hash-verified

592}
593
594function expandObj(node, type, val) {
595 let wrap = document.createElement("span")
596 let opening = type == "array" ? "[" : "{", cname
597 if (opening == "{" && (cname = constructorName(val))) opening = cname + " {"
598 wrap.appendChild(document.createTextNode(opening))
599 let block = wrap.appendChild(document.createElement("div"))
600 block.className = "sandbox-output-etc-block"
601 let table = block.appendChild(document.createElement("table"))
602 function addProp(name) {
603 let row = table.appendChild(document.createElement("tr"))
604 row.appendChild(document.createElement("td")).appendChild(span("prop", name + ":"))
605 row.appendChild(document.createElement("td")).appendChild(represent(val[name], 40))
606 }
607 if (type == "array") {
608 for (let i = 0; i < val.length; ++i) addProp(i)
609 } else {
610 for (let prop in val) if (hop(val, prop)) addProp(prop)
611 }
612 wrap.appendChild(document.createTextNode(type == "array" ? "]" : "}"))
613 node.parentNode.replaceChild(wrap, node)
614}
615
616function awaitEvent(target, event) {
617 return new Promise(accept => {

Callers 3

representArrayFunction · 0.85
representObjFunction · 0.85
representSimpleObjFunction · 0.85

Calls 3

addPropFunction · 0.85
constructorNameFunction · 0.70
hopFunction · 0.70

Tested by

no test coverage detected