MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / prettyPrint

Function prettyPrint

debug-plugin/content-script.js:280–309  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

278 };
279
280 const prettyPrint = function (obj) {
281 if (obj == null) return "null";
282
283 let result;
284
285 if (Element.prototype.isPrototypeOf(obj)) {
286 result =
287 '&lt;<span class="token tagname">' +
288 obj.tagName.toLowerCase() +
289 "</span>";
290 for (const attr of Array.from(obj.attributes)) {
291 if (attr.specified)
292 result +=
293 ' <span class="token attr">' +
294 attr.nodeName +
295 '</span>=<span class="token string">"' +
296 truncate(attr.textContent, 10) +
297 '"</span>';
298 }
299 result += ">";
300 return result;
301 } else if (obj.call) {
302 if (obj.hyperfunc) result = "def " + obj.hypername + " ...";
303 else result = "function " + obj.name + "(...) {...}";
304 } else if (obj.toString) {
305 result = obj.toString();
306 }
307
308 return escapeHTML((result || "undefined").trim());
309 };
310
311 const getCounter = function () {
312 return hdbCounter;

Callers 1

makeConsoleHistoryEntryFunction · 0.85

Calls 3

truncateFunction · 0.85
escapeHTMLFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected