From 33d511b3a1a1b054e715b1d51c21e03c444c4ff0 Mon Sep 17 00:00:00 2001
From: Sascha Schulz <sschulz@dh-software.de>
Date: Mo, 22 Jul 2024 16:11:54 +0200
Subject: [PATCH] add stream example

---
 templates/010-nodejs/stream.js |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/templates/010-nodejs/stream.js b/templates/010-nodejs/stream.js
new file mode 100644
index 0000000..777636b
--- /dev/null
+++ b/templates/010-nodejs/stream.js
@@ -0,0 +1,13 @@
+const fs = require("fs");
+
+const readStream = fs.createReadStream("./in.txt");
+const writeStream = fs.createWriteStream("./out.txt");
+
+readStream.on("data", (data /* Buffer */) => {
+    // process data here
+    writeStream.write(data)
+});
+
+readStream.on("end", (data) => {
+    // stream has finished, e.g. EOF (end of file)
+});

--
Gitblit v1.9.3