From 5ae33d6d3db0594b9b540e72e446b2d7ecd55737 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 146f712c4a2..afef1edfb0b 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -764,7 +764,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. @@ -829,7 +829,7 @@ function pipeOnDrain(src, dest) { } if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) && - EE.listenerCount(src, 'data')) { + src.listenerCount('data')) { src.resume(); } };