diff options
author | Mohammad Sulaiman <mohammad.sulaiman@exalt.ps> | 2024-10-15 01:04:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-14 15:04:18 -0700 |
commit | 8dbe77dd29a3791db58fda392dea45d8249b6bc9 (patch) | |
tree | 1fb57b9d4cbad21455afee71937a17ab6804315c /ext/console | |
parent | 48cbf85add1a9a5c3e583c68c80d16420e606502 (diff) |
fix(console/ext/repl): support using parseFloat() (#25900)
Fixes #21428
Co-authored-by: tannal <tannal2409@gmail.com>
Diffstat (limited to 'ext/console')
-rw-r--r-- | ext/console/01_console.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/console/01_console.js b/ext/console/01_console.js index d9acc958a..a977a2719 100644 --- a/ext/console/01_console.js +++ b/ext/console/01_console.js @@ -84,6 +84,7 @@ const { NumberIsInteger, NumberIsNaN, NumberParseInt, + NumberParseFloat, NumberPrototypeToFixed, NumberPrototypeToString, NumberPrototypeValueOf, @@ -3010,20 +3011,18 @@ function inspectArgs(args, inspectOptions = { __proto__: null }) { } else if (ArrayPrototypeIncludes(["d", "i"], char)) { // Format as an integer. const value = args[a++]; - if (typeof value == "bigint") { - formattedArg = `${value}n`; - } else if (typeof value == "number") { - formattedArg = `${NumberParseInt(String(value))}`; - } else { + if (typeof value === "symbol") { formattedArg = "NaN"; + } else { + formattedArg = `${NumberParseInt(value)}`; } } else if (char == "f") { // Format as a floating point value. const value = args[a++]; - if (typeof value == "number") { - formattedArg = `${value}`; - } else { + if (typeof value === "symbol") { formattedArg = "NaN"; + } else { + formattedArg = `${NumberParseFloat(value)}`; } } else if (ArrayPrototypeIncludes(["O", "o"], char)) { // Format as an object. |