bufferhelper
Advanced tools
Comparing version 0.2.0 to 0.2.1
var BufferHelper = function () { | ||
this.buffers = []; | ||
this.size = 0; | ||
Object.defineProperty(this, 'length', { | ||
get: function () { | ||
return this.size; | ||
} | ||
}); | ||
}; | ||
@@ -7,2 +13,3 @@ | ||
this.buffers.push(buffer); | ||
this.size += buffer.length; | ||
return this; | ||
@@ -13,2 +20,3 @@ }; | ||
this.buffers = []; | ||
this.size = 0; | ||
return this; | ||
@@ -18,3 +26,3 @@ }; | ||
BufferHelper.prototype.toBuffer = function () { | ||
return Buffer.concat(this.buffers); | ||
return Buffer.concat(this.buffers, this.size); | ||
}; | ||
@@ -21,0 +29,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Concat buffer correctly.", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"homepage": "https://github.com/JacksonTian/bufferhelper", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -15,2 +15,3 @@ var BufferHelper = require('../'); | ||
bh.concat(buffer); | ||
bh.length.should.be.equal(6); | ||
bh.toBuffer().should.have.length(buffer.length); | ||
@@ -17,0 +18,0 @@ bh.buffers.should.have.length(1); |
Sorry, the diff of this file is not supported yet
4835
8
65