readSync(reader, buffer, 0, 12, BigInt(position))
Everytime.
It should read from the position in the file, and it will if you use Number(position) on a BigInt position.
The call reads data into the buffer but it begins at position 0 in the file instead of at the position noted in the BigInt.
Also happens w/ fs.read
This is the same behaviour fs.read and fs.readSync have with anything that is not a Number or fails Number.isSafeInteger.
I think this is a reasonable improvement. Though it might be misleading since people may assume fs.read will work with offsets larger than integers which it doesn't.
I think a fix would be to:
typeof of the argument is a BigInt, if it is, coerce it to a Number and pass it to the same IsSafeInteger check.test-fs-read in test/parallel.A more elaborate fix would be to try and get reads to work with position > Int32, which would require:
static void Read(const FunctionCallbackInfo<Value>& args) IsSafeJsInt check in line 2039IsBigInt() and if so read it as a BigInt (an int64 is _probably_ still fine for _most_ cases since a 64 bit offset into a file is 9,223,372,036,854,775,807 bytes big which is still quite theoretical I believe).Instead of coercing the value to a number, I'd in fact throw an error. That way there's just a single way to do this and the immediate feedback should be fine to let the user handle the coercing on their own or to use a number instead.
@BridgeAR Shall I work on this?
If I'm right I have to go here: https://github.com/nodejs/node/blob/master/lib/fs.js#L546-L547 and https://github.com/nodejs/node/blob/master/lib/fs.js#L598-L599 and throw error if typeof position === "bigint" then add a test to test-fs-read in test/parallel.
Though it might be misleading since people may assume fs.read will work with offsets larger than integers which it doesn't.
Why you gotta go and make my max file size 9 petabytes! 馃槶 This is so unreasonable 馃が
j/k
(Removed good first issue because there are at least two open PRs that address this.)
Given that it is perfectly fine to have bigints well within the acceptable range, I'd say that accepting a BigInt should be fine. We can throw a RangeError if too large of a bigint is provided.
if bigint is allowed, would bigdecimal also be allowed if it hypothetically reaches stage 4?
if bigint is allowed, would bigdecimal also be allowed if it hypothetically reaches stage 4?
BigDecimal is currently stage 1, very early in the stage process. I say one bridge at a time.