| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 21a94ab commit 2b52859
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -580,9 +580,10 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
| 580 | 580 | } else if (byteOffset < -0x80000000) { | |
| 581 | 581 | byteOffset = -0x80000000; | |
| 582 | 582 | } | |
| 583 | - byteOffset = +byteOffset; // Coerce to Number. | ||
| 584 | - if (isNaN(byteOffset)) { | ||
| 585 | - // If the offset is undefined, null, NaN, "foo", etc, search whole buffer. | ||
| 583 | + // Coerce to Number. Values like null and [] become 0. | ||
| 584 | + byteOffset = +byteOffset; | ||
| 585 | + // If the offset is undefined, "foo", {}, coerces to NaN, search whole buffer. | ||
| 586 | + if (Number.isNaN(byteOffset)) { | ||
| 586 | 587 | byteOffset = dir ? 0 : (buffer.length - 1); | |
| 587 | 588 | } | |
| 588 | 589 | dir = !!dir; // Cast to bool. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments