@@ -14,31 +14,47 @@ function LazyTransform(options) {
14
14
}
15
15
util . inherits ( LazyTransform , stream . Transform ) ;
16
16
17
- [
18
- '_readableState' ,
19
- '_writableState' ,
20
- '_transformState'
21
- ] . forEach ( function ( prop , i , props ) {
22
- Object . defineProperty ( LazyTransform . prototype , prop , {
23
- get : function ( ) {
24
- stream . Transform . call ( this , this . _options ) ;
25
- this . _writableState . decodeStrings = false ;
26
-
27
- if ( ! this . _options || ! this . _options . defaultEncoding ) {
28
- this . _writableState . defaultEncoding = crypto . DEFAULT_ENCODING ;
29
- }
30
-
31
- return this [ prop ] ;
32
- } ,
33
- set : function ( val ) {
34
- Object . defineProperty ( this , prop , {
35
- value : val ,
36
- enumerable : true ,
37
- configurable : true ,
38
- writable : true
39
- } ) ;
40
- } ,
17
+ function makeGetter ( name ) {
18
+ return function ( ) {
19
+ stream . Transform . call ( this , this . _options ) ;
20
+ this . _writableState . decodeStrings = false ;
21
+
22
+ if ( ! this . _options || ! this . _options . defaultEncoding ) {
23
+ this . _writableState . defaultEncoding = crypto . DEFAULT_ENCODING ;
24
+ }
25
+
26
+ return this [ name ] ;
27
+ } ;
28
+ }
29
+
30
+ function makeSetter ( name ) {
31
+ return function ( val ) {
32
+ Object . defineProperty ( this , name , {
33
+ value : val ,
34
+ enumerable : true ,
35
+ configurable : true ,
36
+ writable : true
37
+ } ) ;
38
+ } ;
39
+ }
40
+
41
+ Object . defineProperties ( LazyTransform . prototype , {
42
+ _readableState : {
43
+ get : makeGetter ( '_readableState' ) ,
44
+ set : makeSetter ( '_readableState' ) ,
45
+ configurable : true ,
46
+ enumerable : true
47
+ } ,
48
+ _writableState : {
49
+ get : makeGetter ( '_writableState' ) ,
50
+ set : makeSetter ( '_writableState' ) ,
51
+ configurable : true ,
52
+ enumerable : true
53
+ } ,
54
+ _transformState : {
55
+ get : makeGetter ( '_transformState' ) ,
56
+ set : makeSetter ( '_transformState' ) ,
41
57
configurable : true ,
42
58
enumerable : true
43
- } ) ;
59
+ }
44
60
} ) ;
0 commit comments