We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d1f08cb commit bd8af71Copy full SHA for bd8af71
buffer-builder.js
@@ -1,11 +1,12 @@
1
module.exports = BufferBuilder;
2
3
function BufferBuilder(initialCapacity) {
4
- initialCapacity = Math.max(1, initialCapacity || 512);
5
- this.buffers = [new Buffer(initialCapacity)];
+ var buffer = Buffer.isBuffer(initialCapacity) ? initialCapacity : new Buffer(initialCapacity || 512);
+ this.buffers = [buffer];
6
+
7
this.writeIndex = 0;
8
this.length = 0;
-};
9
+}
10
11
/* Append a (subsequence of a) Buffer */
12
BufferBuilder.prototype.appendBuffer = function(source) {
@@ -50,7 +51,7 @@ function makeAppender(encoder, size) {
50
51
}
52
53
return this;
- }
54
+ };
55
56
57
BufferBuilder.prototype.appendUInt8 = makeAppender(Buffer.prototype.writeUInt8, 1);
0 commit comments