@@ -137,3 +137,101 @@ function importedBufferInput() {
137137 }
138138 } ) ;
139139}
140+
141+ class HookDestination extends Writable {
142+ constructor ( value ) {
143+ super ( ) ;
144+ this . value = value ;
145+ }
146+
147+ _write ( chunk , encoding , callback ) {
148+ consumeChunk ( chunk ) ; // $ MISSING: flow=write-hook flow=inherited-write-hook
149+ consumeChunk ( this . value ) ; // $ MISSING: flow=hook-receiver
150+ consumeChunk ( encoding ) ;
151+ consumeChunk ( callback ) ;
152+ callback ( ) ;
153+ }
154+ }
155+
156+ Readable . from ( [ source ( "write-hook" ) ] ) . pipe ( new HookDestination ( source ( "hook-receiver" ) ) ) ;
157+
158+ class InheritedHookDestination extends HookDestination { }
159+
160+ const DestinationAlias = InheritedHookDestination ;
161+ const inheritedDestination = new DestinationAlias ( ) ;
162+ const inheritedAlias = inheritedDestination ;
163+ Readable . from ( [ source ( "inherited-write-hook" ) ] ) . pipe ( inheritedAlias ) ;
164+
165+ const { Transform, Duplex } = require ( "stream" ) ;
166+
167+ class HookTransform extends Transform {
168+ _transform ( chunk , encoding , callback ) {
169+ consumeChunk ( chunk ) ; // $ MISSING: flow=transform-hook
170+ callback ( null , chunk ) ;
171+ }
172+ }
173+
174+ Readable . from ( [ source ( "transform-hook" ) ] ) . pipe ( new HookTransform ( ) ) ;
175+
176+ class OverriddenWriteDestination extends Writable {
177+ write ( chunk ) {
178+ consumeChunk ( chunk ) ; // $ flow=overridden-write flow=inherited-overridden-write
179+ return true ;
180+ }
181+
182+ _write ( chunk , encoding , callback ) {
183+ consumeChunk ( chunk ) ;
184+ callback ( ) ;
185+ }
186+ }
187+
188+ Readable . from ( [ source ( "overridden-write" ) ] ) . pipe ( new OverriddenWriteDestination ( ) ) ;
189+
190+ class IntermediateWriteDestination extends OverriddenWriteDestination { }
191+ class InheritedWriteDestination extends IntermediateWriteDestination { }
192+
193+ Readable . from ( [ source ( "inherited-overridden-write" ) ] ) . pipe ( new InheritedWriteDestination ( ) ) ;
194+
195+ class HookDuplex extends Duplex {
196+ _read ( ) { }
197+
198+ _write ( chunk , encoding , callback ) {
199+ consumeChunk ( chunk ) ; // $ MISSING: flow=duplex-hook
200+ callback ( ) ;
201+ }
202+ }
203+
204+ Readable . from ( [ source ( "duplex-hook" ) ] ) . pipe ( new HookDuplex ( ) ) ;
205+
206+ class OverriddenTransform extends Transform {
207+ _write ( chunk , encoding , callback ) {
208+ consumeChunk ( chunk ) ; // $ MISSING: flow=transform-write-hook flow=inherited-transform-write-hook
209+ callback ( ) ;
210+ }
211+
212+ _transform ( chunk , encoding , callback ) {
213+ consumeChunk ( chunk ) ;
214+ callback ( null , chunk ) ;
215+ }
216+ }
217+
218+ Readable . from ( [ source ( "transform-write-hook" ) ] ) . pipe ( new OverriddenTransform ( ) ) ;
219+
220+ class IntermediateTransform extends OverriddenTransform { }
221+ class InheritedTransform extends IntermediateTransform { }
222+
223+ Readable . from ( [ source ( "inherited-transform-write-hook" ) ] ) . pipe ( new InheritedTransform ( ) ) ;
224+
225+ class InstanceOverrideDestination extends Writable {
226+ _write ( chunk , encoding , callback ) {
227+ consumeChunk ( chunk ) ;
228+ callback ( ) ;
229+ }
230+ }
231+
232+ const instanceOverride = new InstanceOverrideDestination ( ) ;
233+ instanceOverride . write = function ( chunk ) {
234+ consumeChunk ( chunk ) ; // $ flow=instance-override
235+ return true ;
236+ } ;
237+ Readable . from ( [ source ( "instance-override" ) ] ) . pipe ( instanceOverride ) ;
0 commit comments