Skip to content

Commit fef731c

Browse files
committed
lib: use Number.parseFloat from primordials
1 parent 99bed01 commit fef731c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/.eslintrc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ rules:
7171
message: "Use `const { WeakMap } = primordials;` instead of the global."
7272
- name: WeakSet
7373
message: "Use `const { WeakSet } = primordials;` instead of the global."
74+
- name: parseFloat
75+
message: "Use `const { NumberParseFloat } = primordials;` instead of the global."
7476
- name: parseInt
7577
message: "Use `const { NumberParseInt } = primordials;` instead of the global."
7678
no-restricted-syntax:

lib/internal/util/inspect.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const {
2929
MathSqrt,
3030
Number,
3131
NumberIsNaN,
32+
NumberParseFloat,
3233
NumberParseInt,
3334
NumberPrototypeValueOf,
3435
Object,
@@ -1960,7 +1961,8 @@ function formatWithOptionsInternal(inspectOptions, ...args) {
19601961
if (typeof tempFloat === 'symbol') {
19611962
tempStr = 'NaN';
19621963
} else {
1963-
tempStr = formatNumber(stylizeNoColor, parseFloat(tempFloat));
1964+
tempStr = formatNumber(stylizeNoColor,
1965+
NumberParseFloat(tempFloat));
19641966
}
19651967
break;
19661968
case 99: // 'c'

lib/repl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const {
4646
Error,
4747
MathMax,
4848
NumberIsNaN,
49+
NumberParseFloat,
4950
ObjectAssign,
5051
ObjectCreate,
5152
ObjectDefineProperty,
@@ -768,7 +769,7 @@ function REPLServer(prompt,
768769
// display next prompt and return.
769770
if (trimmedCmd) {
770771
if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' &&
771-
NumberIsNaN(parseFloat(trimmedCmd))) {
772+
NumberIsNaN(NumberParseFloat(trimmedCmd))) {
772773
const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/);
773774
const keyword = matches && matches[1];
774775
const rest = matches && matches[2];

0 commit comments

Comments
 (0)