Skip to content

Commit 03b13e6

Browse files
Han5991BridgeAR
andauthored
util: remove unreachable code in formatNumber
Remove unreachable decimalIndex === -1 defensive branch. Co-authored-by: Ruben Bridgewater <[email protected]>
1 parent 1d23b55 commit 03b13e6

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

lib/internal/util/inspect.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,20 +1698,7 @@ function formatNumber(fn, number, numericSeparator) {
16981698
return fn(numberString, 'number');
16991699
}
17001700

1701-
// ---------------------------------------------------------------------------
1702-
// From this point on, only *non-integer* numbers will reach the code below.
1703-
// Values where `integer === number` (plain integers, exponential notation,
1704-
// Infinity, etc.) have already been returned in the previous branch.
1705-
// For IEEE-754 doubles within the ±2^53 exact-integer range, `String(number)`
1706-
// never inserts a decimal point, therefore encountering
1707-
// `decimalIndex === -1` in the next lines should be impossible under
1708-
// normal circumstances. (kept here as a defensive fallback)
1709-
// ---------------------------------------------------------------------------
17101701
const decimalIndex = StringPrototypeIndexOf(numberString, '.');
1711-
if (decimalIndex === -1) {
1712-
return fn(numberString, 'number');
1713-
}
1714-
17151702
const integerPart = StringPrototypeSlice(numberString, 0, decimalIndex);
17161703
const fractionalPart = StringPrototypeSlice(numberString, decimalIndex + 1);
17171704

0 commit comments

Comments
 (0)