File tree Expand file tree Collapse file tree 2 files changed +35
-7
lines changed Expand file tree Collapse file tree 2 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,12 @@ var StringDecoder;
1313
1414util . inherits ( Readable , Stream ) ;
1515
16- var prependListener ;
17- if ( typeof EE . prototype . prependListener === 'function' ) {
18- prependListener = function prependListener ( emitter , event , fn ) {
16+ function prependListener ( emitter , event , fn ) {
17+ // Sadly this is not cacheable as some libraries bundle their own
18+ // event emitter implementation with them.
19+ if ( typeof emitter . prependListener === 'function' ) {
1920 return emitter . prependListener ( event , fn ) ;
20- } ;
21- } else {
22- prependListener = function prependListener ( emitter , event , fn ) {
21+ } else {
2322 // This is a hack to make sure that our error handler is attached before any
2423 // userland ones. NEVER DO THIS. This is here only because this code needs
2524 // to continue to work with older versions of Node.js that do not include
@@ -30,7 +29,7 @@ if (typeof EE.prototype.prependListener === 'function') {
3029 emitter . _events [ event ] . unshift ( fn ) ;
3130 else
3231 emitter . _events [ event ] = [ fn , emitter . _events [ event ] ] ;
33- } ;
32+ }
3433}
3534
3635function ReadableState ( options , stream ) {
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ const stream = require ( 'stream' ) ;
4+ const util = require ( 'util' ) ;
5+
6+ function Writable ( ) {
7+ this . writable = true ;
8+ stream . Writable . call ( this ) ;
9+ this . prependListener = undefined ;
10+ }
11+ util . inherits ( Writable , stream . Writable ) ;
12+ Writable . prototype . _write = function ( chunk , end , cb ) {
13+ cb ( ) ;
14+ } ;
15+
16+ function Readable ( ) {
17+ this . readable = true ;
18+ stream . Readable . call ( this ) ;
19+ }
20+ util . inherits ( Readable , stream . Readable ) ;
21+ Readable . prototype . _read = function ( ) {
22+ this . push ( null ) ;
23+ } ;
24+
25+ const w = new Writable ( ) ;
26+ w . on ( 'pipe' , common . mustCall ( function ( ) { } ) ) ;
27+
28+ const r = new Readable ( ) ;
29+ r . pipe ( w ) ;
You can’t perform that action at this time.
0 commit comments