| functionbyteLength(string,encoding){ |
| if(typeofstring!=='string'){ |
| if(isArrayBufferView(string)||isAnyArrayBuffer(string)){ |
| returnstring.byteLength; |
| } |
| |
| thrownewERR_INVALID_ARG_TYPE( |
| 'string',['string','Buffer','ArrayBuffer'],string |
| ); |
| } |
| |
| constlen=string.length; |
| constmustMatch=(arguments.length>2&&arguments[2]===true); |
| if(!mustMatch&&len===0) |
| return0; |
| |
| if(!encoding) |
| return(mustMatch ? -1 : byteLengthUtf8(string)); |
| |
| constops=getEncodingOps(encoding); |
| if(ops===undefined) |
| return(mustMatch ? -1 : byteLengthUtf8(string)); |
| returnops.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.
node/lib/buffer.js
Lines 729 to 752 in f71166b
In line 741 it checks the third argument
mustMatch, which is not mentioned in the documentSo I guess either the implementation or the documentation should be updated.