File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ module.exports = LazyTransform;
11
11
12
12
function LazyTransform ( options ) {
13
13
this . _options = options ;
14
+ this . writable = true ;
15
+ this . readable = true ;
14
16
}
15
17
util . inherits ( LazyTransform , stream . Transform ) ;
16
18
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+ const crypto = require ( 'crypto' ) ;
6
+ const Stream = require ( 'stream' ) ;
7
+ const util = require ( 'util' ) ;
8
+
9
+ const hasher1 = crypto . createHash ( 'sha256' ) ;
10
+ const hasher2 = crypto . createHash ( 'sha256' ) ;
11
+
12
+ // Calculate the expected result.
13
+ hasher1 . write ( Buffer . from ( 'hello world' ) ) ;
14
+ hasher1 . end ( ) ;
15
+
16
+ const expected = hasher1 . read ( ) . toString ( 'hex' ) ;
17
+
18
+ function OldStream ( ) {
19
+ Stream . call ( this ) ;
20
+
21
+ this . readable = true ;
22
+ }
23
+ util . inherits ( OldStream , Stream ) ;
24
+
25
+ const stream = new OldStream ( ) ;
26
+
27
+ stream . pipe ( hasher2 ) . on ( 'finish' , common . mustCall ( function ( ) {
28
+ const hash = hasher2 . read ( ) . toString ( 'hex' ) ;
29
+ assert . strictEqual ( expected , hash ) ;
30
+ } ) ) ;
31
+
32
+ stream . emit ( 'data' , Buffer . from ( 'hello' ) ) ;
33
+ stream . emit ( 'data' , Buffer . from ( ' world' ) ) ;
34
+ stream . emit ( 'end' ) ;
You can’t perform that action at this time.
0 commit comments