- Version: 7.2.0
- Platform: Windows 7
- Subsystem: buffer
Some contradictions in status quo:
buffer.lastIndexOf()code example in doc:
constutf16Buffer=Buffer.from('\u039a\u0391\u03a3\u03a3\u0395','ucs2');// Prints: 6console.log(utf16Buffer.lastIndexOf('\u03a3',null,'ucs2'));Actually, it prints -1 now.
buffer.jscoercesbyteOffsetnull to 0. However, in the next block it checks if byteOffset is null to make it default byteOffset if so.
test-buffer-indexof.jsexpectsnullbyteOffset to return -1, i.e. it expects nullbyteOffset not to be converted into the default byteOffset.
Maybe the fix steps could be these:
buffer.js should not coerce null to Number.test-buffer-indexof.js should expect nullbyteOffset to be converted into the default byteOffset.- Doc should clarify which argument types and values trigger default. Maybe something like
position remarks in the fs doc for fs.read() and fs.write().
Some contradictions in status quo:
buffer.lastIndexOf()code example in doc:Actually, it prints
-1now.buffer.jscoercesbyteOffsetnullto0. However, in the next block it checks ifbyteOffsetisnullto make it defaultbyteOffsetif so.test-buffer-indexof.jsexpectsnullbyteOffsetto return-1, i.e. it expectsnullbyteOffsetnot to be converted into the defaultbyteOffset.Maybe the fix steps could be these:
buffer.jsshould not coercenulltoNumber.test-buffer-indexof.jsshould expectnullbyteOffsetto be converted into the defaultbyteOffset.positionremarks in thefsdoc forfs.read()andfs.write().