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 @@ -1919,7 +1919,8 @@ function ReadStream(path, options) {
1919
1919
this . flags = options . flags === undefined ? 'r' : options . flags ;
1920
1920
this . mode = options . mode === undefined ? 0o666 : options . mode ;
1921
1921
1922
- this . start = options . start ;
1922
+ this . start = typeof this . fd !== 'number' && options . start === undefined ?
1923
+ 0 : options . start ;
1923
1924
this . end = options . end ;
1924
1925
this . autoClose = options . autoClose === undefined ? true : options . autoClose ;
1925
1926
this . pos = undefined ;
Original file line number Diff line number Diff line change @@ -132,6 +132,20 @@ stream.on('end', function() {
132
132
assert . strictEqual ( 'x' , stream . data ) ;
133
133
} ) ;
134
134
135
+ {
136
+ // Verify that end works when start is not specified.
137
+ const stream = new fs . createReadStream ( rangeFile , { end : 1 } ) ;
138
+ stream . data = '' ;
139
+
140
+ stream . on ( 'data' , function ( chunk ) {
141
+ stream . data += chunk ;
142
+ } ) ;
143
+
144
+ stream . on ( 'end' , common . mustCall ( function ( ) {
145
+ assert . strictEqual ( 'xy' , stream . data ) ;
146
+ } ) ) ;
147
+ }
148
+
135
149
// pause and then resume immediately.
136
150
const pauseRes = fs . createReadStream ( rangeFile ) ;
137
151
pauseRes . pause ( ) ;
You can’t perform that action at this time.
0 commit comments