| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dd60859 commit 6549bc2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -588,9 +588,10 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
| 588 | 588 | } else if (byteOffset < -0x80000000) { | |
| 589 | 589 | byteOffset = -0x80000000; | |
| 590 | 590 | } | |
| 591 | - byteOffset = +byteOffset; // Coerce to Number. | ||
| 592 | - if (isNaN(byteOffset)) { | ||
| 593 | - // If the offset is undefined, null, NaN, "foo", etc, search whole buffer. | ||
| 591 | + // Coerce to Number. Values like null and [] become 0. | ||
| 592 | + byteOffset = +byteOffset; | ||
| 593 | + // If the offset is undefined, "foo", {}, coerces to NaN, search whole buffer. | ||
| 594 | + if (Number.isNaN(byteOffset)) { | ||
| 594 | 595 | byteOffset = dir ? 0 : (buffer.length - 1); | |
| 595 | 596 | } | |
| 596 | 597 | dir = !!dir; // Cast to bool. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments