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

Method toString

www/js/ext/component.js:21–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 12

LFunction · 0.45
genUUIDFunction · 0.45
jFunction · 0.45
worker.esm.min.jsFile · 0.45
LFunction · 0.45
workerFuncFunction · 0.45
worker.jsFile · 0.45
workerFuncFunction · 0.45
worker.esm.jsFile · 0.45
jFunction · 0.45
worker.min.jsFile · 0.45
genUUIDFunction · 0.45

Calls 1

currentTokenMethod · 0.45

Tested by

no test coverage detected