-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
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.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.- Doc should clarify which argument types and values trigger default. Maybe something like
positionremarks in thefsdoc forfs.read()andfs.write().
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.