-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Closed
Closed
Copy link
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Description
Lines 729 to 752 in f71166b
function byteLength(string, encoding) { | |
if (typeof string !== 'string') { | |
if (isArrayBufferView(string) || isAnyArrayBuffer(string)) { | |
return string.byteLength; | |
} | |
throw new ERR_INVALID_ARG_TYPE( | |
'string', ['string', 'Buffer', 'ArrayBuffer'], string | |
); | |
} | |
const len = string.length; | |
const mustMatch = (arguments.length > 2 && arguments[2] === true); | |
if (!mustMatch && len === 0) | |
return 0; | |
if (!encoding) | |
return (mustMatch ? -1 : byteLengthUtf8(string)); | |
const ops = getEncodingOps(encoding); | |
if (ops === undefined) | |
return (mustMatch ? -1 : byteLengthUtf8(string)); | |
return ops.byteLength(string); | |
} |
In line 741 it checks the third argument mustMatch
, which is not mentioned in the document
So I guess either the implementation or the documentation should be updated.
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.