MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / toString

Method toString

www/js/_hyperscript.esm.js:26–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24 }
25 // ----- Debug -----
26 toString() {
27 var cur = this.currentToken();
28 var lines = this.source.split("\n");
29 var lineIdx = cur?.line ? cur.line - 1 : lines.length - 1;
30 var col = cur?.line ? cur.column : 0;
31 var contextLine = lines[lineIdx] || "";
32 var tokenLen = Math.max(1, cur?.value?.length || 1);
33 var gutter = String(lineIdx + 1).length;
34 var out = "Tokens(";
35 out += this.#consumed.filter((t) => t.type !== "WHITESPACE").length + " consumed, ";
36 out += this.#tokens.filter((t) => t.type !== "WHITESPACE").length + " remaining";
37 out += ", line " + (lineIdx + 1) + ")\n";
38 out += " " + String(lineIdx + 1).padStart(gutter) + " | " + contextLine + "\n";
39 out += " ".repeat(gutter + 5) + " ".repeat(col) + "^".repeat(tokenLen);
40 if (cur) out += " " + cur.type + " '" + cur.value + "'";
41 return out;
42 }
43 // ----- Token access -----
44 currentToken() {
45 return this.token(0);

Callers 3

_toHTMLFunction · 0.45
getMethod · 0.45

Calls 1

currentTokenMethod · 0.45

Tested by

no test coverage detected