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/node#41871
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Mestery <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
  • Loading branch information
VoltrexKeyva authored and guangwong committed Oct 10, 2022
1 parent 3aa1d99 commit 5ae33d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -829,7 +829,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 5ae33d6

Please sign in to comment.