File tree 2 files changed +16
-1
lines changed 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1942,7 +1942,8 @@ function ReadStream(path, options) {
1942
1942
this . flags = options . flags === undefined ? 'r' : options . flags ;
1943
1943
this . mode = options . mode === undefined ? 0o666 : options . mode ;
1944
1944
1945
- this . start = options . start ;
1945
+ this . start = typeof this . fd !== 'number' && options . start === undefined ?
1946
+ 0 : options . start ;
1946
1947
this . end = options . end ;
1947
1948
this . autoClose = options . autoClose === undefined ? true : options . autoClose ;
1948
1949
this . pos = undefined ;
Original file line number Diff line number Diff line change @@ -157,6 +157,20 @@ assert.throws(function() {
157
157
} ) ) ;
158
158
}
159
159
160
+ {
161
+ // Verify that end works when start is not specified.
162
+ const stream = new fs . createReadStream ( rangeFile , { end : 1 } ) ;
163
+ stream . data = '' ;
164
+
165
+ stream . on ( 'data' , function ( chunk ) {
166
+ stream . data += chunk ;
167
+ } ) ;
168
+
169
+ stream . on ( 'end' , common . mustCall ( function ( ) {
170
+ assert . strictEqual ( 'xy' , stream . data ) ;
171
+ } ) ) ;
172
+ }
173
+
160
174
{
161
175
// pause and then resume immediately.
162
176
const pauseRes = fs . createReadStream ( rangeFile ) ;
You can’t perform that action at this time.
0 commit comments