- Version: 7.2.0
- Platform: Windows 7
- Subsystem: buffer
Some contradictions in status quo:
buffer.lastIndexOf() code example in doc:
const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
// Prints: 6
console.log(utf16Buffer.lastIndexOf('\u03a3', null, 'ucs2'));
Actually, it prints -1 now.
-
buffer.js coerces byteOffset null to 0. However, in the next block it checks if byteOffset is null to make it default byteOffset if so.
-
test-buffer-indexof.js expects null byteOffset to return -1, i.e. it expects null byteOffset 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 null byteOffset 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().