[Pkg-javascript-commits] [node-bl] 02/05: Imported Upstream version 0.9.1

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Tue Sep 9 16:37:55 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-bl.

commit 88ec044eaa72ba8d46cc4c6291997bf6831b9efc
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Tue Sep 9 16:24:26 2014 +0000

    Imported Upstream version 0.9.1
---
 README.md          |  6 +++---
 bl.js              |  5 ++++-
 package.json       |  2 +-
 test/basic-test.js | 17 +++++++++++++++++
 4 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 8e77009..386fbd5 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,8 @@
 
 **A Node.js Buffer list collector, reader and streamer thingy.**
 
-[![NPM](https://nodei.co/npm/bl.png?downloads=true)](https://nodei.co/npm/bl/)
-[![NPM](https://nodei.co/npm-dl/bl.png?months=6)](https://nodei.co/npm/bl/)
+[![NPM](https://nodei.co/npm/bl.png?downloads=true&downloadRank=true)](https://nodei.co/npm/bl/)
+[![NPM](https://nodei.co/npm-dl/bl.png?months=6&height=3)](https://nodei.co/npm/bl/)
 
 **bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them!
 
@@ -121,7 +121,7 @@ Get the length of the list in bytes. This is the sum of the lengths of all of th
 --------------------------------------------------------
 <a name="append"></a>
 ### 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.
 
 --------------------------------------------------------
 <a name="get"></a>
diff --git a/bl.js b/bl.js
index 36c9816..d1ea3b5 100644
--- a/bl.js
+++ b/bl.js
@@ -49,7 +49,10 @@ BufferList.prototype._offset = function (offset) {
 }
 
 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
   return this
 }
diff --git a/package.json b/package.json
index ef53a6d..ec4a47e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "bl",
-  "version": "0.8.2",
+  "version": "0.9.1",
   "description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
   "main": "bl.js",
   "scripts": {
diff --git a/test/basic-test.js b/test/basic-test.js
index 129658a..75116a3 100644
--- a/test/basic-test.js
+++ b/test/basic-test.js
@@ -76,6 +76,23 @@ tape('multiple bytes from multiple buffers', function (t) {
   t.end()
 })
 
+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) {
   var bl = new BufferList()
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-bl.git



More information about the Pkg-javascript-commits mailing list