Previous implementation would copy the Uint8Array into a new Buffer object,
and then concatenate it. It is faster to use the Uint8Array.set (which Buffer.copy
uses internally) anyways.
for (i = 0; i < list.length; ++i) {
var buf = list[i]
if (isInstance(buf, Uint8Array)) {
- buf = Buffer.from(buf)
- }
- if (!Buffer.isBuffer(buf)) {
+ Uint8Array.prototype.set.call(
+ buffer,
+ buf,
+ pos
+ )
+ } else if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers')
+ } else {
+ buf.copy(buffer, pos)
}
- buf.copy(buffer, pos)
pos += buf.length
}
return buffer