summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan José Arboleda <soyjuanarbol@gmail.com>2019-06-23 23:05:45 -0500
committerMichaël Zasso <targos@protonmail.com>2019-07-22 21:20:41 +0200
commitcf811ecd47cf2c4f5bec2b27577c6d414842b703 (patch)
treef4ba30b1d0da9d2fffa1ce7f39181e22df22cc0e
parent06991cd9023b8e00989d3b78844274deebd14b45 (diff)
downloadandroid-node-v8-cf811ecd47cf2c4f5bec2b27577c6d414842b703.tar.gz
android-node-v8-cf811ecd47cf2c4f5bec2b27577c6d414842b703.tar.bz2
android-node-v8-cf811ecd47cf2c4f5bec2b27577c6d414842b703.zip
doc: add code example to subprocess.stdout
PR-URL: https://github.com/nodejs/node/pull/28402 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
-rw-r--r--doc/api/child_process.md10
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/api/child_process.md b/doc/api/child_process.md
index c822864c65..f001ee3c76 100644
--- a/doc/api/child_process.md
+++ b/doc/api/child_process.md
@@ -1398,6 +1398,16 @@ then this will be `null`.
`subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will
refer to the same value.
+```js
+const { spawn } = require('child_process');
+
+const subprocess = spawn('ls');
+
+subprocess.stdout.on('data', (data) => {
+ console.log(`Received chunk ${data}`);
+});
+```
+
### subprocess.unref()
<!-- YAML
added: v0.7.10