| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e520039 commit cff14bc
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -738,17 +738,16 @@ function byteLength(string, encoding) { | |||
| 738 | 738 | } | |
| 739 | 739 | ||
| 740 | 740 | const len = string.length; | |
| 741 | - const mustMatch = (arguments.length > 2 && arguments[2] === true); | ||
| 742 | - if (!mustMatch && len === 0) | ||
| 741 | + if (len === 0) | ||
| 743 | 742 | return 0; | |
| 744 | 743 | ||
| 745 | - if (!encoding) | ||
| 746 | - return (mustMatch ? -1 : byteLengthUtf8(string)); | ||
| 747 | - | ||
| 748 | - const ops = getEncodingOps(encoding); | ||
| 749 | - if (ops === undefined) | ||
| 750 | - return (mustMatch ? -1 : byteLengthUtf8(string)); | ||
| 751 | - return ops.byteLength(string); | ||
| 744 | + if (encoding) { | ||
| 745 | + const ops = getEncodingOps(encoding); | ||
| 746 | + if (ops) { | ||
| 747 | + return ops.byteLength(string); | ||
| 748 | + } | ||
| 749 | + } | ||
| 750 | + return byteLengthUtf8(string); | ||
| 752 | 751 | } | |
| 753 | 752 | ||
| 754 | 753 | Buffer.byteLength = byteLength; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,8 +23,6 @@ const vm = require('vm'); | |||
| 23 | 23 | ); | |
| 24 | 24 | }); | |
| 25 | 25 | ||
| 26 | - assert.strictEqual(Buffer.byteLength('', undefined, true), -1); | ||
| 27 | - | ||
| 28 | 26 | assert(ArrayBuffer.isView(new Buffer(10))); | |
| 29 | 27 | assert(ArrayBuffer.isView(new SlowBuffer(10))); | |
| 30 | 28 | assert(ArrayBuffer.isView(Buffer.alloc(10))); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments