mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: use Number.parseFloat from primordials
PR-URL: https://github.com/nodejs/node/pull/35499 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
This commit is contained in:
committed by
Node.js GitHub Bot
parent
a073f532da
commit
070873649c
@@ -71,6 +71,8 @@ rules:
|
||||
message: "Use `const { WeakMap } = primordials;` instead of the global."
|
||||
- name: WeakSet
|
||||
message: "Use `const { WeakSet } = primordials;` instead of the global."
|
||||
- name: parseFloat
|
||||
message: "Use `const { NumberParseFloat } = primordials;` instead of the global."
|
||||
- name: parseInt
|
||||
message: "Use `const { NumberParseInt } = primordials;` instead of the global."
|
||||
no-restricted-syntax:
|
||||
|
||||
@@ -29,6 +29,7 @@ const {
|
||||
MathSqrt,
|
||||
Number,
|
||||
NumberIsNaN,
|
||||
NumberParseFloat,
|
||||
NumberParseInt,
|
||||
NumberPrototypeValueOf,
|
||||
Object,
|
||||
@@ -1960,7 +1961,8 @@ function formatWithOptionsInternal(inspectOptions, ...args) {
|
||||
if (typeof tempFloat === 'symbol') {
|
||||
tempStr = 'NaN';
|
||||
} else {
|
||||
tempStr = formatNumber(stylizeNoColor, parseFloat(tempFloat));
|
||||
tempStr = formatNumber(stylizeNoColor,
|
||||
NumberParseFloat(tempFloat));
|
||||
}
|
||||
break;
|
||||
case 99: // 'c'
|
||||
|
||||
10
lib/repl.js
10
lib/repl.js
@@ -46,6 +46,7 @@ const {
|
||||
Error,
|
||||
MathMax,
|
||||
NumberIsNaN,
|
||||
NumberParseFloat,
|
||||
ObjectAssign,
|
||||
ObjectCreate,
|
||||
ObjectDefineProperty,
|
||||
@@ -58,7 +59,9 @@ const {
|
||||
PromiseRace,
|
||||
RegExp,
|
||||
Set,
|
||||
StringPrototypeCharAt,
|
||||
StringPrototypeIncludes,
|
||||
StringPrototypeMatch,
|
||||
Symbol,
|
||||
SyntaxError,
|
||||
SyntaxErrorPrototype,
|
||||
@@ -767,9 +770,10 @@ function REPLServer(prompt,
|
||||
// Check to see if a REPL keyword was used. If it returns true,
|
||||
// display next prompt and return.
|
||||
if (trimmedCmd) {
|
||||
if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' &&
|
||||
NumberIsNaN(parseFloat(trimmedCmd))) {
|
||||
const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/);
|
||||
if (StringPrototypeCharAt(trimmedCmd, 0) === '.' &&
|
||||
StringPrototypeCharAt(trimmedCmd, 1) !== '.' &&
|
||||
NumberIsNaN(NumberParseFloat(trimmedCmd))) {
|
||||
const matches = StringPrototypeMatch(trimmedCmd, /^\.([^\s]+)\s*(.*)$/);
|
||||
const keyword = matches && matches[1];
|
||||
const rest = matches && matches[2];
|
||||
if (_parseREPLKeyword.call(self, keyword, rest) === true) {
|
||||
|
||||
Reference in New Issue
Block a user