bl
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -52,3 +52,6 @@ var DuplexStream = require('readable-stream').Duplex | ||
BufferList.prototype.append = function (buf) { | ||
this._bufs.push(Buffer.isBuffer(buf) ? buf : new Buffer(buf)) | ||
var isBuffer = Buffer.isBuffer(buf) || | ||
buf instanceof BufferList | ||
this._bufs.push(isBuffer ? buf : new Buffer(buf)) | ||
this.length += buf.length | ||
@@ -55,0 +58,0 @@ return this |
{ | ||
"name": "bl", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!", | ||
@@ -5,0 +5,0 @@ "main": "bl.js", |
@@ -124,3 +124,3 @@ # bl *(BufferList)* | ||
### bl.append(buffer) | ||
`append(buffer)` adds an additional buffer to the internal list. | ||
`append(buffer)` adds an additional buffer or BufferList to the internal list. | ||
@@ -127,0 +127,0 @@ -------------------------------------------------------- |
@@ -79,2 +79,19 @@ var tape = require('tape') | ||
tape('multiple bytes from multiple buffer lists', function (t) { | ||
var bl = new BufferList() | ||
bl.append(new BufferList([new Buffer('abcd'), new Buffer('efg')])) | ||
bl.append(new BufferList([new Buffer('hi'), new Buffer('j')])) | ||
t.equal(bl.length, 10) | ||
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij') | ||
t.equal(bl.slice(3, 10).toString('ascii'), 'defghij') | ||
t.equal(bl.slice(3, 6).toString('ascii'), 'def') | ||
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh') | ||
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij') | ||
t.end() | ||
}) | ||
tape('consuming from multiple buffers', function (t) { | ||
@@ -81,0 +98,0 @@ var bl = new BufferList() |
NPM Shrinkwrap
Supply chain riskPackage contains a shrinkwrap file. This may allow the package to bypass normal install procedures.
Found 1 instance in 1 package
34695
11
669
1