@@ -2026,30 +2026,27 @@ ReadStream.prototype._read = function(n) {
2026
2026
return this . push ( null ) ;
2027
2027
2028
2028
// the actual read.
2029
- var self = this ;
2030
- fs . read ( this . fd , pool , pool . used , toRead , this . pos , onread ) ;
2031
-
2032
- // move the pool positions, and internal position for reading.
2033
- if ( this . pos !== undefined )
2034
- this . pos += toRead ;
2035
- pool . used += toRead ;
2036
-
2037
- function onread ( er , bytesRead ) {
2029
+ fs . read ( this . fd , pool , pool . used , toRead , this . pos , ( er , bytesRead ) => {
2038
2030
if ( er ) {
2039
- if ( self . autoClose ) {
2040
- self . destroy ( ) ;
2031
+ if ( this . autoClose ) {
2032
+ this . destroy ( ) ;
2041
2033
}
2042
- self . emit ( 'error' , er ) ;
2034
+ this . emit ( 'error' , er ) ;
2043
2035
} else {
2044
2036
var b = null ;
2045
2037
if ( bytesRead > 0 ) {
2046
- self . bytesRead += bytesRead ;
2038
+ this . bytesRead += bytesRead ;
2047
2039
b = thisPool . slice ( start , start + bytesRead ) ;
2048
2040
}
2049
2041
2050
- self . push ( b ) ;
2042
+ this . push ( b ) ;
2051
2043
}
2052
- }
2044
+ } ) ;
2045
+
2046
+ // move the pool positions, and internal position for reading.
2047
+ if ( this . pos !== undefined )
2048
+ this . pos += toRead ;
2049
+ pool . used += toRead ;
2053
2050
} ;
2054
2051
2055
2052
@@ -2143,7 +2140,7 @@ fs.FileWriteStream = fs.WriteStream; // support the legacy name
2143
2140
2144
2141
2145
2142
WriteStream . prototype . open = function ( ) {
2146
- fs . open ( this . path , this . flags , this . mode , function ( er , fd ) {
2143
+ fs . open ( this . path , this . flags , this . mode , ( er , fd ) => {
2147
2144
if ( er ) {
2148
2145
if ( this . autoClose ) {
2149
2146
this . destroy ( ) ;
@@ -2154,7 +2151,7 @@ WriteStream.prototype.open = function() {
2154
2151
2155
2152
this . fd = fd ;
2156
2153
this . emit ( 'open' , fd ) ;
2157
- } . bind ( this ) ) ;
2154
+ } ) ;
2158
2155
} ;
2159
2156
2160
2157
@@ -2168,15 +2165,14 @@ WriteStream.prototype._write = function(data, encoding, cb) {
2168
2165
} ) ;
2169
2166
}
2170
2167
2171
- var self = this ;
2172
- fs . write ( this . fd , data , 0 , data . length , this . pos , function ( er , bytes ) {
2168
+ fs . write ( this . fd , data , 0 , data . length , this . pos , ( er , bytes ) => {
2173
2169
if ( er ) {
2174
- if ( self . autoClose ) {
2175
- self . destroy ( ) ;
2170
+ if ( this . autoClose ) {
2171
+ this . destroy ( ) ;
2176
2172
}
2177
2173
return cb ( er ) ;
2178
2174
}
2179
- self . bytesWritten += bytes ;
2175
+ this . bytesWritten += bytes ;
2180
2176
cb ( ) ;
2181
2177
} ) ;
2182
2178
0 commit comments