MCPcopy Index your code
hub / github.com/pyscript/pyscript / interact

Function interact

core/src/plugins/py-terminal/mpy.js:43–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 // to bootstrap a REPL like environment
42 interpreter.registerJsModule("code", {
43 interact() {
44 const encoder = new TextEncoderStream();
45 encoder.readable.pipeTo(
46 new WritableStream({
47 write(buffer) {
48 for (const c of buffer) interpreter.replProcessChar(c);
49 },
50 }),
51 );
52
53 const writer = encoder.writable.getWriter();
54 sync.pyterminal_stream_write = (buffer) => writer.write(buffer);
55
56 interpreter.replInit();
57 },
58 });
59
60 pyterminal_ready();

Callers

nothing calls this directly

Calls 2

onDataMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected