- Version: 7.3.0
- Platform: OS X 10.12.2
- Subsystem: buffer
The documentation for readIntLE() and readIntBE() both indicate that the second argument (byteLength) is required. However, both functions will seem to operate without a byteLength provided. Unfortunately, byteLength will default to 0 in that case, which results in unpredictable behavior:
> var buf = Buffer.from([126, 127, 128, 129, 130])
undefined
> buf.readIntLE(0)
126
> buf.readIntBE(0)
undefined
> buf.readIntBE(4)
128
> buf.readIntLE(4)
129
>
Perhaps we should do one of the following?:
- have
byteLength default to 1 rather than 0
- throw an error if
byteLength is not provided
- warn in the documentation that if you fail to provide
byteLength, then you will get a result but there are no guarantees even about the return value type