(
options: StdWriteOpts | {},
setOps: (ops: Writer) => void,
getDefaults: () => StdWriteOpts,
)
| 462 | type StdWriteOptsAll = Partial<BatchedWriteHandler & RawWriteHandler & Writer>; |
| 463 | |
| 464 | function _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) |
no test coverage detected
searching dependent graphs…