diff --git a/package.json b/package.json index 7358c8fb..17e3674f 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "eslint-plugin-standard": "4.0.0", "istanbul": "0.4.5", "mocha": "6.0.2", - "supertest": "4.0.0" + "supertest": "4.0.0", + "unpipe": "1.0.0" }, "files": [ "LICENSE", diff --git a/test/compression.js b/test/compression.js index dd8cb17a..9b01fecd 100644 --- a/test/compression.js +++ b/test/compression.js @@ -5,6 +5,7 @@ var bytes = require('bytes') var crypto = require('crypto') var http = require('http') var request = require('supertest') +var unpipe = require('unpipe') var zlib = require('zlib') var compression = require('..') @@ -456,12 +457,6 @@ describe('compression()', function () { }) it('should not leak event listeners when res.unpipe() is used (#135)', function (done) { - // unpipe and stream.Readable were added in v0.9.4 - var stream = require('stream') - if (!(stream.Readable && stream.Readable.prototype.unpipe)) { - this.skip() - } - var hasWarned = false var onWarning = function () { hasWarned = true @@ -471,7 +466,7 @@ describe('compression()', function () { var int = setInterval(function () { var rs = require('fs').createReadStream('does not exist') rs.on('error', function (e) { - rs.unpipe(res) + unpipe(rs) }) rs.pipe(res) if (times++ > res.getMaxListeners()) {