Skip to content

Commit

Permalink
stream: avoid usage of deprecated APIs
Browse files Browse the repository at this point in the history
Avoid usage of the `events.listenerCount()` method as it is
deprecated.

PR-URL: nodejs#41871
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
  • Loading branch information
VoltrexKeyva authored and bengl committed Feb 21, 2022
1 parent a4b1a09 commit be7cc04
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/streams/readable.js
Expand Up @@ -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.
Expand Down Expand Up @@ -852,7 +852,7 @@ function pipeOnDrain(src, dest) {
}

if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) &&
EE.listenerCount(src, 'data')) {
src.listenerCount('data')) {
src.resume();
}
};
Expand Down

0 comments on commit be7cc04

Please sign in to comment.