MCPcopy
hub / github.com/pyodide/pyodide / _setStdwrite

Function _setStdwrite

src/js/streams.ts:464–496  ·  view source on GitHub ↗
(
  options: StdWriteOpts | {},
  setOps: (ops: Writer) => void,
  getDefaults: () => StdWriteOpts,
)

Source from the content-addressed store, hash-verified

462type StdWriteOptsAll = Partial<BatchedWriteHandler & RawWriteHandler & Writer>;
463
464function _setStdwrite(
465 options: StdWriteOpts | {},
466 setOps: (ops: Writer) => void,
467 getDefaults: () => StdWriteOpts,
468) {
469 let opts = options as StdWriteOptsAll;
470 let { raw, isatty, batched, write } = opts;
471 if (!raw && !write && isatty) {
472 throw new TypeError(
473 "Cannot set 'isatty' to true unless 'raw' or 'write' is provided",
474 );
475 }
476 let nset = +!!raw + +!!batched + +!!write;
477 if (nset > 1) {
478 throw new TypeError(
479 "At most one of 'raw', 'batched', and 'write' must be passed",
480 );
481 }
482 if (nset === 0) {
483 opts = getDefaults();
484 ({ raw, isatty, batched, write } = opts);
485 }
486 if (raw) {
487 setOps(new CharacterCodeWriter(opts as RawWriteHandler));
488 }
489 if (batched) {
490 setOps(new StringWriter(batched.bind(opts)));
491 }
492 if (write) {
493 setOps(opts as Writer);
494 }
495 refreshStreams();
496}
497
498/**
499 * If in node, sets stdout to write directly to process.stdout and sets isatty(stdout)

Callers 2

setStdoutFunction · 0.85
setStderrFunction · 0.85

Calls 2

refreshStreamsFunction · 0.85
bindMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…