From 3e38506d1b0b98276cbccb6edc76307f23476c7e Mon Sep 17 00:00:00 2001 From: Mohammed Keyvanzadeh Date: Mon, 7 Feb 2022 01:14:13 +0330 Subject: [PATCH] stream: avoid usage of deprecated APIs Avoid usage of the `events.listenerCount()` method as it is deprecated. PR-URL: https://github.com/nodejs/node/pull/41871 Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum Reviewed-By: Robert Nagy Reviewed-By: Darshan Sen Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel Reviewed-By: Mestery Reviewed-By: Minwoo Jung --- lib/internal/streams/readable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index bd08a0e55d0e59..270542a9c8c2d3 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -787,7 +787,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) { debug('onerror', er); unpipe(); dest.removeListener('error', onerror); - if (EE.listenerCount(dest, 'error') === 0) { + if (dest.listenerCount('error') === 0) { const s = dest._writableState || dest._readableState; if (s && !s.errorEmitted) { // User incorrectly emitted 'error' directly on the stream. @@ -852,7 +852,7 @@ function pipeOnDrain(src, dest) { } if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) && - EE.listenerCount(src, 'data')) { + src.listenerCount('data')) { src.resume(); } };