Skip to content

Commit

Permalink
Merge pull request #57 from rvagg/rvagg/update
Browse files Browse the repository at this point in the history
readable-stream@3
  • Loading branch information
mcollina committed Feb 28, 2019
2 parents b6284a8 + fe0d2bc commit 808731b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
@@ -1,10 +1,8 @@
sudo: false
language: node_js
node_js:
- '4'
- '6'
- '8'
- '9'
- '10'
branches:
only:
Expand Down
5 changes: 2 additions & 3 deletions bl.js
@@ -1,7 +1,6 @@
'use strict'
var DuplexStream = require('readable-stream').Duplex
, util = require('util')
, Buffer = require('safe-buffer').Buffer

function BufferList (callback) {
if (!(this instanceof BufferList))
Expand Down Expand Up @@ -259,10 +258,10 @@ BufferList.prototype.duplicate = function duplicate () {
}


BufferList.prototype.destroy = function destroy () {
BufferList.prototype._destroy = function _destroy (err, cb) {
this._bufs.length = 0
this.length = 0
this.push(null)
cb(err)
}


Expand Down
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -24,12 +24,11 @@
],
"license": "MIT",
"dependencies": {
"readable-stream": "^2.3.5",
"safe-buffer": "^5.1.1"
"readable-stream": "^3.0.1"
},
"devDependencies": {
"faucet": "0.0.1",
"hash_file": "~0.1.1",
"tape": "~4.9.0"
"tape": "~4.9.1"
}
}
14 changes: 14 additions & 0 deletions test/test.js
Expand Up @@ -683,6 +683,20 @@ tape('destroy no pipe', function (t) {
t.equal(bl.length, 0)
})

tape('destroy with error', function (t) {
t.plan(3)

var bl = new BufferList('alsdkfja;lsdkfja;lsdk')
var err = new Error('kaboom')
bl.destroy(err)
bl.on('error', function (_err) {
t.equal(_err, err)
})

t.equal(bl._bufs.length, 0)
t.equal(bl.length, 0)
})

!process.browser && tape('destroy with pipe before read end', function (t) {
t.plan(2)

Expand Down

0 comments on commit 808731b

Please sign in to comment.