Implement process.stdout, process.stdin, and process.stderr #366
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements
process.stdout,process.stdin, andprocess.stderrfor jstime, providing Node.js-compatible stream interfaces for standard I/O operations.Features
process.stdout and process.stderr
Implemented as writable stream-like objects with the following capabilities:
write(chunk, encoding, callback)- Write strings or Uint8Arrays to stdout/stderrend(chunk, encoding, callback)- Close stream after optional final writeisTTY- Property indicating if stream is connected to a TTY (currently returnsfalse)process.stdin
Implemented as a readable stream-like object with:
read()- Read all available data from stdinisTTY- Property indicating if stream is connected to a TTYExample Usage
Implementation Details
Rust Layer (
core/src/builtins/node/process_impl.rs)write_stdout(),write_stderr(), andread_stdin()functionsJavaScript Layer (
core/src/builtins/node/process.js)ProcessWritableStreamclass for stdout/stderrProcessReadableStreamclass for stdinwrite(),end(), and stream methodsTesting
Added 8 new tests covering:
Documentation
Updated
docs/apis/system.mdto markprocess.stdin/stdout/stderras implemented with basic stream functionality.Compatibility
While this implementation provides the core functionality needed for most use cases, it doesn't include the full Node.js Stream API features like event emitters, piping, or backpressure handling. For basic I/O operations (writing output, reading input), the implementation is fully compatible with Node.js patterns.
Closes #[issue_number]
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.