From 23c31e73fb2ac0eb5fd10ca631d4f1b4fdbaf458 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. --- 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 7dc2e5346afad9..3fcd373cb1c708 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(); } };