bl 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bl.js CHANGED
@@ -52,6 +52,11 @@ BufferList.prototype.append = function (buf) {
52
52
  var isBuffer = Buffer.isBuffer(buf) ||
53
53
  buf instanceof BufferList
54
54
 
55
+ // coerce number arguments to strings, since Buffer(number) does
56
+ // uninitialized memory allocation
57
+ if (typeof buf == 'number')
58
+ buf = buf.toString()
59
+
55
60
  this._bufs.push(isBuffer ? buf : new Buffer(buf))
56
61
  this.length += buf.length
57
62
  return this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bl",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
5
5
  "main": "bl.js",
6
6
  "scripts": {
@@ -28,9 +28,8 @@
28
28
  "readable-stream": "~1.0.26"
29
29
  },
30
30
  "devDependencies": {
31
- "tape": "~2.12.3",
32
- "hash_file": "~0.1.1",
33
31
  "faucet": "~0.0.1",
34
- "brtapsauce": "~0.3.0"
32
+ "hash_file": "~0.1.1",
33
+ "tape": "~4.4.0"
35
34
  }
36
35
  }
@@ -336,6 +336,22 @@ tape('test String appendage', function (t) {
336
336
  t.end()
337
337
  })
338
338
 
339
+ tape('test Number appendage', function (t) {
340
+ var bl = new BufferList()
341
+ , b = new Buffer('1234567890')
342
+
343
+ bl.append(1234)
344
+ bl.append(567)
345
+ bl.append(89)
346
+ bl.append(0)
347
+
348
+ encodings.forEach(function (enc) {
349
+ t.equal(bl.toString(enc), b.toString(enc))
350
+ })
351
+
352
+ t.end()
353
+ })
354
+
339
355
  tape('write nothing, should get empty buffer', function (t) {
340
356
  t.plan(3)
341
357
  BufferList(function (err, data) {