File tree 1 file changed +42
-0
lines changed 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Flags: --expose-internals
2
+ 'use strict' ;
3
+
4
+ require ( '../common' ) ;
5
+ const assert = require ( 'assert' ) ;
6
+ const WrapStream = require ( 'internal/wrap_js_stream' ) ;
7
+ const Stream = require ( 'stream' ) ;
8
+
9
+ class FakeStream extends Stream {
10
+ constructor ( ) {
11
+ super ( ) ;
12
+ this . _paused = false ;
13
+ }
14
+
15
+ pause ( ) {
16
+ this . _paused = true ;
17
+ }
18
+
19
+ resume ( ) {
20
+ this . _paused = false ;
21
+ }
22
+
23
+ isPaused ( ) {
24
+ return this . _paused ;
25
+ }
26
+ }
27
+
28
+ const fakeStreamObj = new FakeStream ( ) ;
29
+ const wrappedStream = new WrapStream ( fakeStreamObj ) ;
30
+
31
+ // Resume by wrapped stream upon construction
32
+ assert . strictEqual ( fakeStreamObj . isPaused ( ) , false ) ;
33
+
34
+ fakeStreamObj . pause ( ) ;
35
+
36
+ assert . strictEqual ( fakeStreamObj . isPaused ( ) , true ) ;
37
+
38
+ fakeStreamObj . resume ( ) ;
39
+
40
+ assert . strictEqual ( wrappedStream . readStop ( ) , 0 ) ;
41
+
42
+ assert . strictEqual ( fakeStreamObj . isPaused ( ) , true ) ;
You can’t perform that action at this time.
0 commit comments