@@ -2091,30 +2091,27 @@ ReadStream.prototype._read = function(n) {
2091
2091
return this . push ( null ) ;
2092
2092
2093
2093
// the actual read.
2094
- var self = this ;
2095
- fs . read ( this . fd , pool , pool . used , toRead , this . pos , onread ) ;
2096
-
2097
- // move the pool positions, and internal position for reading.
2098
- if ( this . pos !== undefined )
2099
- this . pos += toRead ;
2100
- pool . used += toRead ;
2101
-
2102
- function onread ( er , bytesRead ) {
2094
+ fs . read ( this . fd , pool , pool . used , toRead , this . pos , ( er , bytesRead ) => {
2103
2095
if ( er ) {
2104
- if ( self . autoClose ) {
2105
- self . destroy ( ) ;
2096
+ if ( this . autoClose ) {
2097
+ this . destroy ( ) ;
2106
2098
}
2107
- self . emit ( 'error' , er ) ;
2099
+ this . emit ( 'error' , er ) ;
2108
2100
} else {
2109
2101
var b = null ;
2110
2102
if ( bytesRead > 0 ) {
2111
- self . bytesRead += bytesRead ;
2103
+ this . bytesRead += bytesRead ;
2112
2104
b = thisPool . slice ( start , start + bytesRead ) ;
2113
2105
}
2114
2106
2115
- self . push ( b ) ;
2107
+ this . push ( b ) ;
2116
2108
}
2117
- }
2109
+ } ) ;
2110
+
2111
+ // move the pool positions, and internal position for reading.
2112
+ if ( this . pos !== undefined )
2113
+ this . pos += toRead ;
2114
+ pool . used += toRead ;
2118
2115
} ;
2119
2116
2120
2117
ReadStream . prototype . _destroy = function ( err , cb ) {
@@ -2209,7 +2206,7 @@ fs.FileWriteStream = fs.WriteStream; // support the legacy name
2209
2206
2210
2207
2211
2208
WriteStream . prototype . open = function ( ) {
2212
- fs . open ( this . path , this . flags , this . mode , function ( er , fd ) {
2209
+ fs . open ( this . path , this . flags , this . mode , ( er , fd ) => {
2213
2210
if ( er ) {
2214
2211
if ( this . autoClose ) {
2215
2212
this . destroy ( ) ;
@@ -2220,7 +2217,7 @@ WriteStream.prototype.open = function() {
2220
2217
2221
2218
this . fd = fd ;
2222
2219
this . emit ( 'open' , fd ) ;
2223
- } . bind ( this ) ) ;
2220
+ } ) ;
2224
2221
} ;
2225
2222
2226
2223
@@ -2234,15 +2231,14 @@ WriteStream.prototype._write = function(data, encoding, cb) {
2234
2231
} ) ;
2235
2232
}
2236
2233
2237
- var self = this ;
2238
- fs . write ( this . fd , data , 0 , data . length , this . pos , function ( er , bytes ) {
2234
+ fs . write ( this . fd , data , 0 , data . length , this . pos , ( er , bytes ) => {
2239
2235
if ( er ) {
2240
- if ( self . autoClose ) {
2241
- self . destroy ( ) ;
2236
+ if ( this . autoClose ) {
2237
+ this . destroy ( ) ;
2242
2238
}
2243
2239
return cb ( er ) ;
2244
2240
}
2245
- self . bytesWritten += bytes ;
2241
+ this . bytesWritten += bytes ;
2246
2242
cb ( ) ;
2247
2243
} ) ;
2248
2244
0 commit comments