summaryrefslogtreecommitdiff
path: root/lib/_stream_readable.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/_stream_readable.js')
-rw-r--r--lib/_stream_readable.js25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index b031bf0b75..78732ed185 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -40,20 +40,19 @@ const kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
function prependListener(emitter, event, fn) {
// Sadly this is not cacheable as some libraries bundle their own
// event emitter implementation with them.
- if (typeof emitter.prependListener === 'function') {
+ if (typeof emitter.prependListener === 'function')
return emitter.prependListener(event, fn);
- } else {
- // This is a hack to make sure that our error handler is attached before any
- // userland ones. NEVER DO THIS. This is here only because this code needs
- // to continue to work with older versions of Node.js that do not include
- // the prependListener() method. The goal is to eventually remove this hack.
- if (!emitter._events || !emitter._events[event])
- emitter.on(event, fn);
- else if (Array.isArray(emitter._events[event]))
- emitter._events[event].unshift(fn);
- else
- emitter._events[event] = [fn, emitter._events[event]];
- }
+
+ // This is a hack to make sure that our error handler is attached before any
+ // userland ones. NEVER DO THIS. This is here only because this code needs
+ // to continue to work with older versions of Node.js that do not include
+ // the prependListener() method. The goal is to eventually remove this hack.
+ if (!emitter._events || !emitter._events[event])
+ emitter.on(event, fn);
+ else if (Array.isArray(emitter._events[event]))
+ emitter._events[event].unshift(fn);
+ else
+ emitter._events[event] = [fn, emitter._events[event]];
}
function ReadableState(options, stream) {