目录
node.js文档
Buffer.concat(list[, totalLength])
- list <Buffer[]> | <Uint8Array[]> 要合并的 Buffer 数组或 Uint8Array 数组。
- totalLength
合并后 list 中的 Buffer 实例的总长度。 - 返回:
var buf1=Buffer.alloc(10,0);
var buf2=Buffer.alloc(11,0);
var buf3=Buffer.alloc(5,0);
var len=buf1.length+buf2.length+buf3.length;
console.log(`len:${len}`);//26
const bufA=Buffer.concat([buf1,buf2,buf3],len);
console.log(bufA);
//<Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>
console.log(bufA.length);
//26