summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2018-06-08 19:24:11 +0000
committerKyle K <kylek389@gmail.com>2018-06-08 19:24:11 +0000
commit4d719ba0bc7f482c43bffde4309a12bf741527c2 (patch)
treeacb6bc92e244f4595014399b9f766242003ee724
parentbcd40d9580bfd1c08708b265e09d05f38659237e (diff)
downloadjsexamples-4d719ba0bc7f482c43bffde4309a12bf741527c2.tar.gz
jsexamples-4d719ba0bc7f482c43bffde4309a12bf741527c2.tar.bz2
jsexamples-4d719ba0bc7f482c43bffde4309a12bf741527c2.zip
js Streams example
-rw-r--r--streams.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/streams.js b/streams.js
new file mode 100644
index 0000000..74049e3
--- /dev/null
+++ b/streams.js
@@ -0,0 +1,11 @@
+var fs = require('fs');
+var readableStream = fs.createReadStream('/home/kyle//hello.c');
+var fileData = '';
+
+readableStream.on('data', function(chunk) {
+ fileData += chunk;
+});
+
+readableStream.on('end', function() {
+ console.log(fileData);
+});