buffer
buffer copied to clipboard
Use Buffer slice will have wrong result when end is larger than int32.
[1,2,3].slice(1,3) return [2, 3], it's ok.
Array.from( Buffer.from([1,2,3]).slice(1,3) ) return [2,3], it's ok.
Array.from( Buffer.from([1,2,3]).slice(1,Math.pow(2,32)) ) return [] , it's wrong result.
In node Buffer, there is comment:
// Use Math.trunc() to convert offset to an integer value that can be larger
// than an Int32. Hence, don't use offset | 0 or similar techniques.
In this package, Buffer use ~, can't work with larger than int32 number.