Closed jhermsmeier closed 7 years ago
Perhaps it's just me misunderstanding things, but in some places fd
is specified as a Number
, but in other places it's specified as a String
? :confused:
Nope, not just you – I mangled the type. Fixed now.
LGTM, but I don't know the nodejs API well enough to give this "official approval" ;-)
Now that I think about it, I should probably implement the other fs.ReadStream
options as well, to be fully compatible with that API.
I've added the other fs.ReadStream
options (start, end, autoClose) as well now, with exception of mode
, as that's only used when creating a file, which is not applicable in this case.
Should createReadStream be documented as having the same options as new ReadStream?
Should createReadStream be documented as having the same options as new ReadStream?
Yup, fixed.
One more question... ;-)
If we pass in a filename
instead of an fd
, does the autoClose
setting effectively get ignored? Does that need a unit-test?
No, the autoClose
option is not coupled to the fd
option, so if you pass a filename and autoClose: false
, then the readStream.fd
will still be open & usable after the stream has ended.
Test added.
I'd love to see the following test cases:
start
and/or end
are -1end
is 0start
is greater than end
start
is equal to end
start
goes beyond the fileend
goes beyond the fileGood catch! Added tests, and fixed a case they caught.
Connects to: #15
Changes:
fd
option toBlockMap.ReadStream
, so that if passed, thefilename
argument will be ignored, and thefd
used instead (analog to node core'sfs.ReadStream
)start
andend
offset options toBlockMap.ReadStream
autoClose
option toBlockMap.ReadStream
BlockMap.createFilterStream()
, analog to.createReadStream()