MCPcopy Index your code
hub / github.com/RustPython/RustPython / readPrompts

Function readPrompts

wasm/demo/src/index.js:126–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

124}
125
126async function readPrompts() {
127 let continuing = '';
128
129 while (true) {
130 let input = await readline.read(getPrompt(continuing ? 'ps2' : 'ps1'));
131 if (input.endsWith('\n')) input = input.slice(0, -1);
132 if (continuing) {
133 input = continuing += '\n' + input;
134 if (!continuing.endsWith('\n')) continue;
135 }
136 try {
137 console.log([input]);
138 terminalVM.execSingle(input);
139 } catch (err) {
140 if (err.canContinue) {
141 continuing = input;
142 continue;
143 } else if (err instanceof WebAssembly.RuntimeError) {
144 err = window.__RUSTPYTHON_ERROR || err;
145 }
146 readline.print('' + err);
147 }
148 continuing = '';
149 }
150}
151
152function onReady() {
153 snippets.addEventListener('change', updateSnippetAndRun);

Callers 1

onReadyFunction · 0.85

Calls 5

getPromptFunction · 0.85
readMethod · 0.45
sliceMethod · 0.45
logMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected