Use Buffer slice will have wrong result when end is larger than int32.
Open
- Dominant language
- JavaScript
- Stars
- 1.9k
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
`[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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.