{"id":111803,"date":"2021-10-25T07:00:00","date_gmt":"2021-10-25T04:00:00","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=111803"},"modified":"2021-10-19T14:13:48","modified_gmt":"2021-10-19T11:13:48","slug":"readable-and-writable-streams-in-node-js","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html","title":{"rendered":"Readable and Writable Streams in Node.js"},"content":{"rendered":"<p>Hello. In this tutorial, we will explain readable and writable Streams in a Node.js application.<\/p>\n<h2>1. Introduction<\/h2>\n<p>Streams in the node are the objects that help you to write and read data to and from the destination source. There are four different types of streams in node.js:<\/p>\n<ul>\n<li><strong>Readable<\/strong> \u2013 Stream uses for reading operations<\/li>\n<li><strong>Writable<\/strong> \u2013 Stream used for write operations<\/li>\n<li><strong>Duplex<\/strong> \u2013 Stream used for both reading and write operations<\/li>\n<li><strong>Transform<\/strong> \u2013 Type of duplex stream where the output is computed according to the input<\/li>\n<\/ul>\n<p>Each stream consists of several Event emitter events fired at different times \u2013<\/p>\n<ul>\n<li><strong>Data<\/strong> \u2013 Event is fired when data is available to read<\/li>\n<li><strong>End<\/strong> \u2013 Event is fired when there is no more data available to read<\/li>\n<li><strong>Error<\/strong> \u2013 Event is fired when there is an error receiving or writing the data<\/li>\n<li><strong>Finish<\/strong> \u2013 Event is fired when all the data has been flushed<\/li>\n<\/ul>\n<h3>1.1 Setting up Node.js<\/h3>\n<p>To set up <strong>Node.js<\/strong> on windows you will need to download the installer from <a href=\"https:\/\/nodejs.org\/en\/download\/\" target=\"_blank\" rel=\"noopener\">this<\/a> link. Click on the installer (also include the NPM package manager) for your platform and run the installer to start with the Node.js setup wizard. Follow the wizard steps and click on Finish when it is done. If everything goes well you can navigate to the command prompt to verify if the installation was successful as shown in Fig. 1.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/node-npm-installation-img1.jpg\"><img decoding=\"async\" width=\"480\" height=\"91\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/node-npm-installation-img1.jpg\" alt=\"Writable Streams in Node.js - npm installation\" class=\"wp-image-111804\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/node-npm-installation-img1.jpg 480w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/node-npm-installation-img1-300x57.jpg 300w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/a><figcaption>Fig. 1: Verifying node and npm installation<\/figcaption><\/figure>\n<\/div>\n<h2>2. Readable and Writable Streams in Node.js<\/h2>\n<p>To set up the application, we will need to navigate to a path where our project will reside. For programming stuff, I am using <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noopener\">Visual Studio Code<\/a> as my preferred IDE. You&#8217;re free to choose the IDE of your choice.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h3>2.1 Setting up the implementation<\/h3>\n<p>Let us write the different files which will be required for practical learning.<\/p>\n<h4>2.1.1 Setting up dependencies<\/h4>\n<p>Navigate to the project directory and run <code>npm init -y<\/code> to create a <code>package.json<\/code> file. This <a href=\"https:\/\/docs.npmjs.com\/creating-a-package-json-file\" target=\"_blank\" rel=\"noopener\">file<\/a> holds the metadata relevant to the project and is used for managing the project dependencies, script, version, etc. Add the following code to the file wherein we will specify the required dependencies.<\/p>\n<p><span style=\"text-decoration: underline\"><em>package.json<\/em><\/span><\/p>\n<pre class=\"brush:json;\">{\n  \"name\": \"streamdata\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"start\": \"nodemon index.js\",\n    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"faker\": \"^5.5.3\",\n    \"nodemon\": \"^2.0.13\"\n  }\n}\n<\/pre>\n<p>To download the dependencies navigate to the directory path containing the file and use the <code>npm install<\/code> command. If everything goes well the dependencies will be loaded inside the <code>node_modules<\/code> folder and you are good to go with the further steps.<\/p>\n<h4>2.1.2 Creating controller<\/h4>\n<p>In the root folder add the following content to the index file. The file will be exposing 2 endpoints \u2013<\/p>\n<ul>\n<li><code>\/write<\/code> to create a writeable stream and write mock data into a file<\/li>\n<li><code>\/read<\/code> to create a readable stream and read data from the file<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline\"><em>index.js<\/em><\/span><\/p>\n<pre class=\"brush:js;\">const http = require(\"http\");\nconst fs = require(\"fs\");\nconst faker = require(\"faker\");\n\nconst file = \"data.txt\";\n\nconst server = http.createServer(function (req, resp) {\n  if (req.method === \"POST\" &amp;&amp; req.url === \"\/write\") {\n    \/\/ http:\/\/localhost:5001\/write\n    console.log(\"writing data to stream.\");\n    const writeStream = fs.createWriteStream(file);\n    for (let i = 0; i &lt;= 1000; i++) {\n      writeStream.write(faker.lorem.words(20) + \"\\n\");\n    }\n\n    writeStream.end();\n    resp.end();\n  } else if (req.method === \"GET\" &amp;&amp; req.url === \"\/read\") {\n    \/\/ http:\/\/localhost:5001\/read\n    console.log(\"reading data.\");\n    \/\/ getting data in a single chunk\n    \/* fs.readFile(file, (err, data) =&gt; {\n      if (err) throw err;\n      resp.end(data);\n    }); *\/\n\n    \/\/ doing data streaming\n    var data = \"\";\n    const readStream = fs.createReadStream(file);\n    readStream.on(\"data\", (chunk) =&gt; {\n      console.log(\"chunk data received.\");\n      data += chunk;\n    });\n    \/\/ method will be called when no more data is available for read.\n    readStream.on(\"end\", () =&gt; {\n      resp.end(data);\n    });\n  } else {\n    throw new Error(\"NOT_YET_IMPLEMENTED\");\n  }\n});\n\n\/\/ start app\nconst PORT = process.env.PORT || 5001;\nserver.listen(PORT, () =&gt; {\n  console.log(`Server started on port ${PORT}`);\n});\n<\/pre>\n<h2>3. Run the Application<\/h2>\n<p>To run the application navigate to the project directory and enter the following command as shown in Fig. 2. If everything goes well the application will be started successfully on a port number read from the <code>.env<\/code> file or <code>5001<\/code>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/streamdata-run-guide.jpg\"><img decoding=\"async\" width=\"559\" height=\"144\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/streamdata-run-guide.jpg\" alt=\"Writable Streams in Node.js - starting the app\" class=\"wp-image-111805\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/streamdata-run-guide.jpg 559w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/streamdata-run-guide-300x77.jpg 300w\" sizes=\"(max-width: 559px) 100vw, 559px\" \/><\/a><figcaption>Fig. 2: Starting the application<\/figcaption><\/figure>\n<\/div>\n<h2>4. Demo<\/h2>\n<p>You are free to use <a href=\"https:\/\/www.getpostman.com\/\" target=\"_blank\" rel=\"noopener\">postman<\/a> or any other tool of your choice to make the HTTP request to the application endpoints.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Endpoints<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">\/\/ http post - http:\/\/localhost:5001\/write\n\/\/ http get - http:\/\/localhost:5001\/read\n<\/pre>\n<p>That is all for this tutorial and I hope the article served you with whatever you were looking for. Happy Learning and do not forget to share!<\/p>\n<h2>5. Summary<\/h2>\n<p>In this tutorial, we explained readable and writable Streams in a Node.js application. You can download the source code and the postman collection from the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>6. Download the Project<\/h2>\n<p>This was a tutorial to implement Streams in the nodejs application.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/10\/Readable-and-Writable-Streams-in-Node.js_.zip\"><strong>Readable and Writable Streams in Node.js<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello. In this tutorial, we will explain readable and writable Streams in a Node.js application. 1. Introduction Streams in the node are the objects that help you to write and read data to and from the destination source. There are four different types of streams in node.js: Readable \u2013 Stream uses for reading operations Writable &hellip;<\/p>\n","protected":false},"author":26931,"featured_media":20900,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1879],"tags":[803,741],"class_list":["post-111803","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-javascript","tag-node-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Readable and Writable Streams in Node.js - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"There are 4 different types of streams in node.js: Readable: Stream uses for reading operations. Writable: Stream used for write operations\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Readable and Writable Streams in Node.js - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"There are 4 different types of streams in node.js: Readable: Stream uses for reading operations. Writable: Stream used for write operations\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-25T04:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin Batra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin Batra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html\"},\"author\":{\"name\":\"Yatin Batra\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\"},\"headline\":\"Readable and Writable Streams in Node.js\",\"datePublished\":\"2021-10-25T04:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html\"},\"wordCount\":591,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"keywords\":[\"JavaScript\",\"Node.js\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html\",\"name\":\"Readable and Writable Streams in Node.js - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"datePublished\":\"2021-10-25T04:00:00+00:00\",\"description\":\"There are 4 different types of streams in node.js: Readable: Stream uses for reading operations. Writable: Stream used for write operations\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/readable-and-writable-streams-in-node-js.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Readable and Writable Streams in Node.js\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\",\"name\":\"Yatin Batra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"caption\":\"Yatin Batra\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\\\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\\\/\\\/www.javacodegeeks.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yatin-batra\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Readable and Writable Streams in Node.js - Java Code Geeks","description":"There are 4 different types of streams in node.js: Readable: Stream uses for reading operations. Writable: Stream used for write operations","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html","og_locale":"en_US","og_type":"article","og_title":"Readable and Writable Streams in Node.js - Java Code Geeks","og_description":"There are 4 different types of streams in node.js: Readable: Stream uses for reading operations. Writable: Stream used for write operations","og_url":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2021-10-25T04:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","type":"image\/jpeg"}],"author":"Yatin Batra","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin Batra","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html"},"author":{"name":"Yatin Batra","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d"},"headline":"Readable and Writable Streams in Node.js","datePublished":"2021-10-25T04:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html"},"wordCount":591,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","keywords":["JavaScript","Node.js"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html","url":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html","name":"Readable and Writable Streams in Node.js - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","datePublished":"2021-10-25T04:00:00+00:00","description":"There are 4 different types of streams in node.js: Readable: Stream uses for reading operations. Writable: Stream used for write operations","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/readable-and-writable-streams-in-node-js.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/www.javacodegeeks.com\/category\/web-development"},{"@type":"ListItem","position":3,"name":"JavaScript","item":"https:\/\/www.javacodegeeks.com\/category\/web-development\/javascript"},{"@type":"ListItem","position":4,"name":"Readable and Writable Streams in Node.js"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d","name":"Yatin Batra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","caption":"Yatin Batra"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/yatin-batra"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/111803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/26931"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=111803"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/111803\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/20900"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=111803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=111803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=111803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}