diff --git a/lib/bufferwriter.js b/lib/bufferwriter.js index fa8e8cd..a61ff90 100644 --- a/lib/bufferwriter.js +++ b/lib/bufferwriter.js @@ -14,6 +14,10 @@ BufferWriter.prototype.set = function(obj) { return this; }; +BufferWriter.prototype.toBuffer = function() { + return this.concat(); +}; + BufferWriter.prototype.concat = function() { return Buffer.concat(this.bufs); }; diff --git a/test/bufferwriter.js b/test/bufferwriter.js index 7042533..fa4b2b9 100644 --- a/test/bufferwriter.js +++ b/test/bufferwriter.js @@ -22,6 +22,17 @@ describe('BufferWriter', function() { }); + describe('#toBuffer', function() { + + it('should concat these two bufs', function() { + var buf1 = new Buffer([0]); + var buf2 = new Buffer([1]); + var bw = new BufferWriter({bufs: [buf1, buf2]}); + bw.toBuffer().toString('hex').should.equal('0001'); + }); + + }); + describe('#concat', function() { it('should concat these two bufs', function() {