summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAnton Khlynovskiy <subzey@gmail.com>2013-07-08 21:09:44 +0400
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-02-18 13:52:14 -0800
commit1fa5cff4f21782fb1ba499c38e690a13d70ba765 (patch)
tree49fc5650eab6cc5b0d9b0e980cea936b30822cef /doc
parent1d734a75b5764ac7414daab489ce82d6ca09f69f (diff)
downloadnode-1fa5cff4f21782fb1ba499c38e690a13d70ba765.tar.gz
docs: clarify process.stdin and old mode
Diffstat (limited to 'doc')
-rw-r--r--doc/api/process.markdown22
1 files changed, 17 insertions, 5 deletions
diff --git a/doc/api/process.markdown b/doc/api/process.markdown
index 9d3125ce9..dafcd23bd 100644
--- a/doc/api/process.markdown
+++ b/doc/api/process.markdown
@@ -164,22 +164,34 @@ that writes to them are usually blocking.
## process.stdin
-A `Readable Stream` for stdin. The stdin stream is paused by default, so one
-must call `process.stdin.resume()` to read from it.
+A `Readable Stream` for stdin.
Example of opening standard input and listening for both events:
- process.stdin.resume();
process.stdin.setEncoding('utf8');
- process.stdin.on('data', function(chunk) {
- process.stdout.write('data: ' + chunk);
+ process.stdin.on('readable', function(chunk) {
+ var chunk = process.stdin.read();
+ if (chunk !== null) {
+ process.stdout.write('data: ' + chunk);
+ }
});
process.stdin.on('end', function() {
process.stdout.write('end');
});
+As a Stream, `process.stdin` can also be used in "old" mode that is compatible
+with scripts written for node prior v0.10.
+For more information see
+[Stream compatibility](stream.html#stream_compatibility_with_older_node_versions).
+
+In "old" Streams mode the stdin stream is paused by default, so one
+must call `process.stdin.resume()` to read from it. Note also that calling
+`process.stdin.resume()` itself would switch stream to "old" mode.
+
+If you are starting a new project you should prefer a more recent "new" Streams
+mode over "old" one.
## process.argv