mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 09:02:40 +00:00

Now parts of our public and public-ish APIs fall back to old-style
listenerCount() if the emitter does not have a listenerCount function.
Fixes: https://github.com/nodejs/node/issues/2655
Refs: 8f58fb92ff
PR-URL: https://github.com/nodejs/node/pull/2661
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
20 lines
442 B
JavaScript
20 lines
442 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const stream = require('stream');
|
|
|
|
const r = new stream.Stream();
|
|
r.listenerCount = undefined;
|
|
|
|
const w = new stream.Stream();
|
|
w.listenerCount = undefined;
|
|
|
|
w.on('pipe', function() {
|
|
r.emit('error', new Error('Readable Error'));
|
|
w.emit('error', new Error('Writable Error'));
|
|
});
|
|
r.on('error', common.mustCall(noop));
|
|
w.on('error', common.mustCall(noop));
|
|
r.pipe(w);
|
|
|
|
function noop() {};
|