-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Description
- 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
coercesbyteOffset
null
to0
. However, in the next block it checks ifbyteOffset
isnull
to make it defaultbyteOffset
if so. -
test-buffer-indexof.js
expectsnull
byteOffset
to return-1
, i.e. it expectsnull
byteOffset
not to be converted into the defaultbyteOffset
.
Maybe the fix steps could be these:
buffer.js
should not coercenull
toNumber
.test-buffer-indexof.js
should expectnull
byteOffset
to be converted into the defaultbyteOffset
.- Doc should clarify which argument types and values trigger default. Maybe something like
position
remarks in thefs
doc forfs.read()
andfs.write()
.
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.