

{"id":102266,"date":"2021-11-03T09:00:49","date_gmt":"2021-11-03T03:30:49","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=102266"},"modified":"2021-11-10T11:59:11","modified_gmt":"2021-11-10T06:29:11","slug":"nodejs-buffers","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/","title":{"rendered":"Nodejs Buffers"},"content":{"rendered":"<p>Today we will be discussing Nodejs buffers and their properties in detail with code and examples.<\/p>\n<h3>Nodejs Buffers:<\/h3>\n<p>It is an area of memory present outside the v8 javascript engine. It is of fixed size. This is like an array where each item is in bytes.<\/p>\n<h3>Why use a buffer in Nodejs?<\/h3>\n<p>Normally we deal with string data types but in order to deal with binary data types efficiently we have to use buffer.<\/p>\n<h3>Creating Buffers in Nodejs:<\/h3>\n<p>In order to store something on buffer we have to first create a buffer. Below are different ways for creating Buffer:<\/p>\n<p>1. Creating a buffer of size 10 octets which is not initialised<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var buf = Buffer.alloc(10);<\/pre>\n<p>2. Creating buffer for the given array<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var buf = Buffer.from([10, 20, 30, 40, 50]);<\/pre>\n<p>3. Creating buffer for the given string with encoding:<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var buf = Buffer.from(\"DataFlair\", \"utf-8\");<\/pre>\n<h3>Writing to Buffers in Nodejs:<\/h3>\n<p>Now we will look at how to store our data in a buffer. Below syntax shows how we can write to a buffer.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">buf.write(string[, offset][, length][, encoding])<\/pre>\n<h4>Parameter:<\/h4>\n<ul>\n<li>string : It represents the data that has to be written in the buffer.<\/li>\n<li>Offset: This represents the index from where the writing will start.<\/li>\n<li>Length: It represents the number of bytes.<\/li>\n<li>Encoding: It represents the type of encoding, by default it is \u201cUTF8\u201d<\/li>\n<\/ul>\n<h4>Return value:<\/h4>\n<p>It returns the number of octets written. Example of writing to buffer:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">buf = new Buffer(256);\r\nlen = buf.write(\"DataFlair\");\r\nconsole.log(len)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\n<p>9<\/p>\n<h3>Reading from Nodejs Buffers:<\/h3>\n<p>In order to read the data store in our buffer we will be using the below syntax:<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">buf.read([encoding],[, start],[, end])<\/pre>\n<h4>Parameter:<\/h4>\n<ul>\n<li>Encoding: It represents the type of encoding, by default it is \u201cUTF8\u201d<\/li>\n<li>Start: It indicates the index from which reading will start.<\/li>\n<li>End: It represents the index till which it has to read.<\/li>\n<\/ul>\n<h4>Return value:<\/h4>\n<p>It returns the string from the buffer.<\/p>\n<p><strong>Example of reading from a buffer:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var buffer = Buffer.alloc(16)\r\nbuffer.write(\"DataFlair\", \"utf-8\")\r\nconsole.log(buffer.toString(\"utf-8\", 0, 9))\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-write.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-103769\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-write.webp\" alt=\"nodejs buffer write\" width=\"1366\" height=\"726\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-write.webp 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-write-768x408.webp 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>Buffer to Json:<\/h3>\n<p>To convert the buffer data to a json format buffer.toJSON() method is used.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">buffer.toJSON()<\/pre>\n<h4>Return type:<\/h4>\n<p>It returns a json value for the given buffer.<\/p>\n<p><strong>Code for converting buffer to json:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">let buffer = new Buffer('Welcome to DataFlair');\r\nlet json = buffer.toJSON(buffer);\r\nconsole.log(json);<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-to-json.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-103770\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-to-json.webp\" alt=\"nodejs buffer to json\" width=\"1366\" height=\"726\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-to-json.webp 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-to-json-768x408.webp 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h4>Concatenate Buffer:<\/h4>\n<p>It is used to concatenate two buffers together to make a single buffer. Below is syntax for doing the same.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Buffer.concat(list[, totalLength])<\/pre>\n<h4>Parameter:<\/h4>\n<ul>\n<li>List: It is the list of buffers that will be concatenated<br \/>\ntotalLength: Represents the total length after concatenation<\/li>\n<li>Return value:<br \/>\nReturns the concatenated buffer.<\/li>\n<\/ul>\n<p><strong>Example of concatenating buffers:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var buffer1 = new Buffer('Data');\r\nvar buffer2 = new Buffer('Flair');\r\nvar buffer3 = Buffer.concat([buffer1, buffer2]);\r\n\r\nconsole.log(buffer3.toString());\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-concat.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-103771\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-concat.webp\" alt=\"nodejs buffer concat\" width=\"1366\" height=\"726\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-concat.webp 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-concat-768x408.webp 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h4>Iterating over a buffer:<\/h4>\n<p>In order to iterate a buffer use a for loop which you use in javascript.<\/p>\n<p><strong>Code for iterating over a buffer<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const buf = Buffer.from('DataFlair!')\r\nfor (const item of buf) {\r\n    console.log(item)\r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-iterate.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-103772\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-iterate.webp\" alt=\"nodejs buffer iterate\" width=\"1366\" height=\"726\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-iterate.webp 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-iterate-768x408.webp 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h4>Length of Buffer:<\/h4>\n<p>To get the length of the buffer that you have created use the buffer.length() method. It will return a number representing the length of the buffer.<\/p>\n<p><strong>Code to know the length of buffer<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const buf = Buffer.from('DataFlair')\r\nconsole.log(buf.length)\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-length.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-103773\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-length.webp\" alt=\"nodejs buffer length\" width=\"1366\" height=\"726\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-length.webp 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-length-768x408.webp 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>Changing contents of Nodejs buffers:<\/h3>\n<p>When we want to edit our buffer we treat it like an array and replace the content in the same way as we do incase of arrays.<\/p>\n<p><strong>Code for changing the contents of buffer<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const buf = Buffer.from('DataFlair')\r\nbuf[0] = 100\r\nconsole.log(buf.toString())\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-replace.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-103774\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-replace.webp\" alt=\"nodejs buffer replace\" width=\"1366\" height=\"726\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-replace.webp 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-replace-768x408.webp 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>Slicing buffer in Nodejs:<\/h3>\n<p>Slicing is used when we want to get a particular part from our buffer.<\/p>\n<p><strong>Code for Slicing the buffer:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const buf = Buffer.from('DataFlair')\r\nconst slice = buf.subarray(0, 4)\r\nconsole.log(slice.toString())\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-slice.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-103775\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-slice.webp\" alt=\"nodejs buffer slice\" width=\"1366\" height=\"726\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-slice.webp 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-buffer-slice-768x408.webp 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>Copy Nodejs buffer:<\/h3>\n<p>To copy data from one buffer to another we make another buffer of the same size and then set the content of the buffer.<\/p>\n<p><strong>Code for Copying a buffer:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">const buf = Buffer.from('DataFlair')\r\nlet bufcopy = Buffer.alloc(9)\r\nbufcopy.set(buf)\r\nconsole.log(bufcopy.toString())\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-copy-buffer.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-103776\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-copy-buffer.webp\" alt=\"nodejs copy buffer\" width=\"1366\" height=\"726\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-copy-buffer.webp 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/10\/nodejs-copy-buffer-768x408.webp 768w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h4>Compare Nodejs buffers:<\/h4>\n<p>To compare one buffer with another we use the buffer.compare method.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">buffer.compare(\u2018anotherBufferName\u2019)<\/pre>\n<p><strong>Code for Comparing Nodejs buffers:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">let buffer1 = new Buffer('Hello from DataFlair');\r\nlet buffer2 = new Buffer('Welcome to DataFlair');\r\nlet result = buffer1.compare(buffer2);\r\nif (result &lt; 0) {\r\n    console.log(buffer1 + \" comes before \" + buffer2);\r\n} else if (result === 0) {\r\n    console.log(buffer1 + \" is same as \" + buffer2);\r\n} else {\r\n    console.log(buffer1 + \" comes after \" + buffer2);\r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Hello from DataFlair comes before Welcome to DataFlair.<\/div>\n<h4>Methods Reference:<\/h4>\n<ul>\n<li>\n<h5>Comparing buffer:<\/h5>\n<\/li>\n<\/ul>\n<p>To compare two buffers we use the buffer.compare(buf1,buf2)<\/p>\n<ul>\n<li>\n<h5>isBuffer:<\/h5>\n<\/li>\n<\/ul>\n<p>To know whether the given object is a buffer or not we use the buffer.isBuffer(obj) method.<\/p>\n<ul>\n<li>\n<h5>isEncoding:<\/h5>\n<\/li>\n<\/ul>\n<p>It returns true if the encoding provided is a valid encoding.<\/p>\n<h3>Summary<\/h3>\n<p>In this article, we discussed Nodejs buffers and their different properties. Hope you liked the article.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today we will be discussing Nodejs buffers and their properties in detail with code and examples. Nodejs Buffers: It is an area of memory present outside the v8 javascript engine. It is of fixed&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":103989,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25259],"tags":[25665,25661,25660,25663,25664,25662],"class_list":["post-102266","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js-tutorials","tag-changing-contents-of-nodejs-buffers","tag-creating-buffers-in-nodejs","tag-nodejs-buffers","tag-reading-from-nodejs-buffers","tag-slicing-a-buffer-in-nodejs","tag-writing-to-buffers-in-nodejs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Nodejs Buffers - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn about nodejs buffers. Learn to create &amp; concatenate buffer, write to buffer, reading from buffer, buffer to json conversion, etc.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nodejs Buffers - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn about nodejs buffers. Learn to create &amp; concatenate buffer, write to buffer, reading from buffer, buffer to json conversion, etc.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-03T03:30:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-10T06:29:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/11\/nodejs-buffers.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nodejs Buffers - DataFlair","description":"Learn about nodejs buffers. Learn to create & concatenate buffer, write to buffer, reading from buffer, buffer to json conversion, etc.","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:\/\/data-flair.training\/blogs\/nodejs-buffers\/","og_locale":"en_US","og_type":"article","og_title":"Nodejs Buffers - DataFlair","og_description":"Learn about nodejs buffers. Learn to create & concatenate buffer, write to buffer, reading from buffer, buffer to json conversion, etc.","og_url":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2021-11-03T03:30:49+00:00","article_modified_time":"2021-11-10T06:29:11+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/11\/nodejs-buffers.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"Nodejs Buffers","datePublished":"2021-11-03T03:30:49+00:00","dateModified":"2021-11-10T06:29:11+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/"},"wordCount":631,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/11\/nodejs-buffers.webp","keywords":["Changing contents of Nodejs buffers","Creating Buffers in Nodejs","Nodejs Buffers","Reading from Nodejs Buffers","Slicing a buffer in Nodejs","Writing to Buffers in Nodejs"],"articleSection":["Node Js Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/nodejs-buffers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/","url":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/","name":"Nodejs Buffers - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/11\/nodejs-buffers.webp","datePublished":"2021-11-03T03:30:49+00:00","dateModified":"2021-11-10T06:29:11+00:00","description":"Learn about nodejs buffers. Learn to create & concatenate buffer, write to buffer, reading from buffer, buffer to json conversion, etc.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/nodejs-buffers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/11\/nodejs-buffers.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/11\/nodejs-buffers.webp","width":1200,"height":628,"caption":"nodejs buffers"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/nodejs-buffers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Node Js Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/node-js-tutorials\/"},{"@type":"ListItem","position":3,"name":"Nodejs Buffers"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team is a group of passionate educators and industry experts dedicated to providing high-quality online learning resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With years of experience in the field, the team aims to simplify complex topics and help learners advance their careers. At DataFlair, we believe in empowering students and professionals with the knowledge and skills needed to thrive in today\u2019s fast-paced tech industry. Follow us for Free courses, expert insights, tutorials, and practical tips to boost your learning journey.","url":"https:\/\/data-flair.training\/blogs\/author\/datafbdad\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/102266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=102266"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/102266\/revisions"}],"predecessor-version":[{"id":103779,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/102266\/revisions\/103779"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/103989"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=102266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=102266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=102266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}