MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / onCodeInput

Function onCodeInput

src/lib/console.js:217–239  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

215 }
216
217 function onCodeInput(e) {
218 const key = e.key;
219 isFocused = true;
220 if (key === "Enter") {
221 const regex = /[\[|{\(\)\}\]]/g;
222 let code = this.value.trim();
223 let isOdd = (code.length - code.replace(regex, "").length) % 2;
224
225 if (!code || isOdd) return;
226 e.preventDefault();
227 e.stopPropagation();
228 e.stopImmediatePropagation();
229
230 log("code", {}, code);
231 $input.value = "";
232 const res = execute(code);
233 if (res.type === "error") {
234 log("error", getStack(new Error()), res.value);
235 } else {
236 log("log", getStack(new Error()), res.value);
237 }
238 }
239 }
240
241 function getBody(obj, ...keys) {
242 if (obj instanceof Promise && !("[[PromiseStatus]]" in obj))

Callers

nothing calls this directly

Calls 5

executeFunction · 0.85
getStackFunction · 0.85
logFunction · 0.70
preventDefaultMethod · 0.45
stopPropagationMethod · 0.45

Tested by

no test coverage detected