From fa57c9fa9dc8eb6e55d8f9f0c49013ad45f08030 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Jul 2020 00:17:24 -0400 Subject: [PATCH] WIP test all node.js unpipe --- package.json | 3 ++- test/compression.js | 9 ++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index b957c7a7..40013f01 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "eslint-plugin-standard": "4.0.0", "istanbul": "0.4.5", "mocha": "6.2.0", - "supertest": "4.0.2" + "supertest": "4.0.2", + "unpipe": "1.0.0" }, "files": [ "LICENSE", diff --git a/test/compression.js b/test/compression.js index d1045acb..aa4a06c6 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()) {