[Pkg-javascript-commits] [node-concat-stream] 01/11: New upstream version 1.6.0

Ross Gammon ross-guest at moszumanska.debian.org
Sat May 20 14:39:29 UTC 2017


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

ross-guest pushed a commit to branch master
in repository node-concat-stream.

commit 6b4ad0f17b9a1e684870c3a49bccc5105e61feb5
Author: Ross Gammon <rosco2 at ubuntu.com>
Date:   Sat May 20 14:40:47 2017 +0200

    New upstream version 1.6.0
---
 collaborators.md   |  7 +++++++
 index.js           | 19 +++++++++++++------
 package.json       | 10 +++++-----
 readme.md          |  4 +++-
 test/string.js     | 15 +++++++++++++--
 test/typedarray.js |  6 +++---
 6 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/collaborators.md b/collaborators.md
new file mode 100644
index 0000000..510524d
--- /dev/null
+++ b/collaborators.md
@@ -0,0 +1,7 @@
+## Collaborators
+
+concat-stream is only possible due to the excellent work of the following collaborators:
+
+<table><tbody><tr><th align="left">maxogden</th><td><a href="https://github.com/maxogden">GitHub/maxogden</a></td></tr>
+<tr><th align="left">mafintosh</th><td><a href="https://github.com/mafintosh">GitHub/mafintosh</a></td></tr>
+</tbody></table>
diff --git a/index.js b/index.js
index b55ae7e..b16ad13 100644
--- a/index.js
+++ b/index.js
@@ -73,6 +73,10 @@ function isArrayish (arr) {
   return /Array\]$/.test(Object.prototype.toString.call(arr))
 }
 
+function isBufferish (p) {
+  return typeof p === 'string' || isArrayish(p) || (p && typeof p.subarray === 'function')
+}
+
 function stringConcat (parts) {
   var strings = []
   var needsToString = false
@@ -82,8 +86,10 @@ function stringConcat (parts) {
       strings.push(p)
     } else if (Buffer.isBuffer(p)) {
       strings.push(p)
+    } else if (isBufferish(p)) {
+      strings.push(new Buffer(p))
     } else {
-      strings.push(Buffer(p))
+      strings.push(new Buffer(String(p)))
     }
   }
   if (Buffer.isBuffer(parts[0])) {
@@ -101,10 +107,11 @@ function bufferConcat (parts) {
     var p = parts[i]
     if (Buffer.isBuffer(p)) {
       bufs.push(p)
-    } else if (typeof p === 'string' || isArrayish(p)
-    || (p && typeof p.subarray === 'function')) {
-      bufs.push(Buffer(p))
-    } else bufs.push(Buffer(String(p)))
+    } else if (isBufferish(p)) {
+      bufs.push(new Buffer(p))
+    } else {
+      bufs.push(new Buffer(String(p)))
+    }
   }
   return Buffer.concat(bufs)
 }
@@ -121,7 +128,7 @@ function u8Concat (parts) {
   var len = 0
   for (var i = 0; i < parts.length; i++) {
     if (typeof parts[i] === 'string') {
-      parts[i] = Buffer(parts[i])
+      parts[i] = new Buffer(parts[i])
     }
     len += parts[i].length
   }
diff --git a/package.json b/package.json
index 5c3de72..cd908ed 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "concat-stream",
-  "version": "1.5.1",
+  "version": "1.6.0",
   "description": "writable stream that concatenates strings or binary data and calls a callback with the result",
   "tags": [
     "stream",
@@ -28,12 +28,12 @@
   },
   "license": "MIT",
   "dependencies": {
-    "inherits": "~2.0.1",
-    "typedarray": "~0.0.5",
-    "readable-stream": "~2.0.0"
+    "inherits": "^2.0.3",
+    "typedarray": "^0.0.6",
+    "readable-stream": "^2.2.2"
   },
   "devDependencies": {
-    "tape": "~2.3.2"
+    "tape": "^4.6.3"
   },
   "testling": {
     "files": "test/*.js",
diff --git a/readme.md b/readme.md
index 1a16af9..f45e6fc 100644
--- a/readme.md
+++ b/readme.md
@@ -16,7 +16,7 @@ There are also `objectMode` streams that emit things other than Buffers, and you
 
 ## Related
 
-`stream-each` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.
+`concat-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.
 
 ### examples
 
@@ -89,6 +89,8 @@ By default `concat-stream` will give you back the same data type as the type of
 
 If you don't specify an encoding, and the types can't be inferred (e.g. you write things that aren't in the list above), it will try to convert concat them into a `Buffer`.
 
+If nothing is written to `writable` then `data` will be an empty array `[]`.
+
 # error handling
 
 `concat-stream` does not handle errors for you, so you must handle errors on whatever streams you pipe into `concat-stream`. This is a general rule when programming with node.js streams: always handle errors on each and every stream. Since `concat-stream` is not itself a stream it does not emit errors.
diff --git a/test/string.js b/test/string.js
index 218c522..be60998 100644
--- a/test/string.js
+++ b/test/string.js
@@ -42,7 +42,7 @@ test('string from mixed write encodings', function (t) {
     t.equal(out, 'nacho dogs')
   })
   strings.write('na')
-  strings.write(Buffer('cho'))
+  strings.write(new Buffer('cho'))
   strings.write([ 32, 100 ])
   var u8 = new U8(3)
   u8[0] = 111; u8[1] = 103; u8[2] = 115;
@@ -58,7 +58,7 @@ test('string from buffers with multibyte characters', function (t) {
   var snowman = new Buffer('☃')
   for (var i = 0; i < 8; i++) {
     strings.write(snowman.slice(0, 1))
-    strings.write(snowman.slice(1))    
+    strings.write(snowman.slice(1))
   }
   strings.end()
 })
@@ -74,3 +74,14 @@ test('string infer encoding with empty string chunk', function (t) {
   strings.write("dogs")
   strings.end()
 })
+
+test('to string numbers', function (t) {
+  var write = concat(function (str) {
+    t.equal(str, 'a1000')
+    t.end()
+  })
+
+  write.write('a')
+  write.write(1000)
+  write.end()
+})
diff --git a/test/typedarray.js b/test/typedarray.js
index ee07110..5630b66 100644
--- a/test/typedarray.js
+++ b/test/typedarray.js
@@ -14,7 +14,7 @@ test('typed array stream', function (t) {
 
   var arrays = concat({ encoding: 'Uint8Array' }, function(out) {
     t.equal(typeof out.subarray, 'function')
-    t.deepEqual(Buffer(out).toString('utf8'), 'abcde fg xyz')
+    t.deepEqual(new Buffer(out).toString('utf8'), 'abcde fg xyz')
   })
   arrays.write(a)
   arrays.write(b)
@@ -25,9 +25,9 @@ test('typed array from strings, buffers, and arrays', function (t) {
   t.plan(2)
   var arrays = concat({ encoding: 'Uint8Array' }, function(out) {
     t.equal(typeof out.subarray, 'function')
-    t.deepEqual(Buffer(out).toString('utf8'), 'abcde fg xyz')
+    t.deepEqual(new Buffer(out).toString('utf8'), 'abcde fg xyz')
   })
   arrays.write('abcde')
-  arrays.write(Buffer(' fg '))
+  arrays.write(new Buffer(' fg '))
   arrays.end([ 120, 121, 122 ])
 })

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



More information about the Pkg-javascript-commits mailing list