new Buffer(number)            // Old
Buffer.alloc(number)          // New

new Buffer(string)            // Old
Buffer.from(string)           // New

new Buffer(string, encoding)  // Old
Buffer.from(string, encoding) // New

new Buffer(...arguments)      // Old
Buffer.from(...arguments)     // New

Note that Buffer.alloc() is also faster on the current Node.js versions than new Buffer(size).fill(0), which is what you would otherwise need to ensure zero-filling.

Answer from Nebojsa Sapic on Stack Overflow
🌐
Node.js
nodejs.org › api › buffer.html
Buffer | Node.js v26.11.1 Documentation
The Buffer module pre-allocates an internal Buffer instance of size Buffer.poolSize that is used as a pool for the fast allocation of new Buffer instances created using Buffer.allocUnsafe(), Buffer.from(array), Buffer.from(string), and Buffer.concat() only when size is less than Buffer.poolSize >>> 1 (floor of Buffer.poolSize divided by two).
🌐
GitHub
github.com › mscdex › busboy › issues › 251
Buffer() is deprecated due to security and usability issues · Issue #251 · mscdex/busboy
September 3, 2021 - export function parseMultipartFormData(event) { return new Promise((resolve, reject) => { const busboy = new Busboy({ headers: { 'content-type': event.headers['Content-Type'], }, }); const body = {}; busboy.on('file', (fieldname, file, filename, encoding, mimetype) => { body.filename = filename; body.encoding = encoding; body.mimetype = mimetype; const buffer = []; file .on('data', (chunk) => { buffer.push(chunk); }) .on('end', () => { body.documentContent = Buffer.concat(buffer); }); }) .on('field', (fieldname, val) => { body[fieldname] = val; }) .on('finish', () => { resolve(body); }) .on('error', (err) => { reject(err); }); busboy.end(event.body); }); } When I execute this function I am getting a warning, (node:8) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues.
Author: mscdex
🌐
W3Schools
w3schools.com › nodejs › met_buffer_concat.asp
Node.js Buffer.concat() Method
The concat() method joins all buffer objects in an array into one buffer object.
🌐
W3Schools
w3schools.com › nodejs › nodejs_buffer.asp
Node.js Buffer Module
binary: Binary encoding (deprecated) ucs2/utf16le: 2 or 4 bytes, little-endian encoded Unicode characters · You can combine multiple buffers into one using Buffer.concat(): const buf1 = Buffer.from('Hello, '); const buf2 = Buffer.from('Node.js!'); // Concatenate buffers const combined = Buffer.concat([buf1, buf2]); console.log(combined.toString()); // 'Hello, Node.js!'
🌐
npm
npmjs.com › package › buffer-concat
buffer-concat - npm
August 2, 2016 - Node.js 0.8.0 and newer provides this functionality out of the box on the native buffer object (Buffer.concat). If you rather this module work as a polyfill, you can require it as such: require('buffer-concat/polyfill').
      » npm install buffer-concat
    
Published: Aug 02, 2016
Version: 1.0.0
🌐
Appmarq
appmarq.com › public › tqi,1020782,Avoid-using-Buffer-deprecated-APIs
Avoid using Buffer deprecated APIs
Rule Definition Using deprecated Node.js API could lead to security compliancy issues. The Buffer() function and new Buffer() constructor are deprecated due to API usability issues that can potentially lead to accidental security issues. As an alternative, use of the following methods of ...
🌐
TutorialsPoint
tutorialspoint.com › nodejs › nodejs_buffers.htm
Node.js - Buffers
Returns a new Buffer which is the result of concatenating all the Buffer instances.
Find elsewhere
🌐
GitHub
github.com › nodejs › help › issues › 1994
Buffer.concatenate only produces buffer of last buffer ...
June 21, 2019 - I am trying to concatenate an array of buffers using the Buffer.concat() function. From the documentation it appears that the first input is an array of buffers, and the second input is the buffer total length. I then convert that to a string and pass it to another function to be emailed to the client...
Author: nodejs
🌐
W3Resource
w3resource.com › node.js › nodejs-buffer.php
Using Buffers in Node.js - w3resource<
November 13, 2023 - Buffer.byteLength(string, [encoding]) method is used to get the actual byte length of a string with a given encoding. Arguments : Return Value : Actual byte length of a string. Value Type : number. In the following examples, actual string length of 'A' is 1 byte, whereas length of '\u00bd' is 2 bytes. Concat two for more buffers : Buffer.concat(list, [totalLength] The Buffer.concat(list, [totalLength]) method is used to concatenate two or more buffers/strings.
🌐
GeeksforGeeks
geeksforgeeks.org › node-js-buffer-concat-method
Node.js Buffer.concat() Method | GeeksforGeeks
April 11, 2023 - The Buffer.concat() method is used to concat all buffer objects in a given array into one buffer object. The return value of this method is also a buffer.
🌐
GitHub
github.com › nodejs › node › issues › 59985
Buffer#copy (and Buffer.concat) can read/write process memory on certain input · Issue #59985 · nodejs/node
September 23, 2025 - let l const b = new Uint8Array(1).fill(1) Object.defineProperty(b, 'length', { get: () => l }) Object.defineProperty(b, 'byteLength', { get: () => l }) for (l = 1000; l < 1e5; l+=100) { const c = Buffer.concat([b]) const i = c.indexOf('executable_path') if (i >= 0) { const e = c.subarray(i).toString() if (e.length > 1000) { // whatever console.log(e) break } } }
Author: nodejs
🌐
LogRocket
blog.logrocket.com › home › node.js buffer: a complete guide
Node.js buffer: A complete guide - LogRocket Blog
June 4, 2024 - var buffer1 = Buffer.from('x'); var buffer2 = Buffer.from('y'); var buffer3 = Buffer.from('z'); var arr = [buffer1, buffer2, buffer3]; /*This will print buffer, !concat [ <Buffer 78>, <Buffer 79>, <Buffer 7a> ]*/ console.log(arr); //concatenate buffer with Buffer.concat method var buf = Buffer.concat(arr); //This will print <Buffer 78 79 7a> concat successful console.log(buf);
🌐
GitHub
github.com › nodejs › node-v0.x-archive › issues › 8621
Encoding of Buffer.concat() · Issue #8621 · nodejs/node-v0.x-archive
October 25, 2014 - As I found the 'binary' encoding to produce correct hash values, I started to assume that the usage of Buffer.concat() by the implementation I'm extending may cause trouble. As far as I can see, buffers of different encodings are concatenated into new buffers.
Author: nodejs
🌐
DEV Community
dev.to › m__mdy__m › buffers-in-nodejs-1fh2
Buffers in Node.js - DEV Community
December 14, 2023 - Use Case: Assembling multiple chunks into a single data stream, such as aggregating buffer chunks from a file read stream. ... // Example: Concatenate multiple buffers into one const buf1 = Buffer.from('Hello '); const buf2 = Buffer.from('World'); const combinedBuffer = Buffer.concat([buf1, buf2]); console.log(combinedBuffer.toString()); // Outputs: 'Hello World'
🌐
Node.js
nodejs.org › download › release › v10.2.0 › docs › api › buffer.html
Buffer | Node.js v10.2.0 Documentation
Returns a new Buffer which is the result of concatenating all the Buffer instances in the list together.
🌐
GitHub
github.com › nodejs › node › issues › 55422
`Buffer.concat` and `Buffer.copy` silently produce invalid results when the operation involves indices equal or greater than 2^32 · Issue #55422 · nodejs/node
October 17, 2024 - Version v22.9.0, v23.0.0 Platform Windows 11 x64 Microsoft Windows NT 10.0.22631.0 x64 Subsystem Buffer What steps will reproduce the bug? const largeBuffer = Buffer.alloc(2 ** 32 + 5) largeBuffer.fill(111) const result = Buffer.concat([...
Author: nodejs