| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 77f1e1e commit 5d727f0
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,6 +71,8 @@ rules: | |||
| 71 | 71 | message: "Use `const { WeakMap } = primordials;` instead of the global." | |
| 72 | 72 | - name: WeakSet | |
| 73 | 73 | message: "Use `const { WeakSet } = primordials;` instead of the global." | |
| 74 | + - name: parseInt | ||
| 75 | + message: "Use `const { NumberParseInt } = primordials;` instead of the global." | ||
| 74 | 76 | no-restricted-syntax: | |
| 75 | 77 | # Config copied from .eslintrc.js | |
| 76 | 78 | - error | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ const { | |||
| 25 | 25 | ArrayIsArray, | |
| 26 | 26 | NumberIsInteger, | |
| 27 | 27 | NumberIsNaN, | |
| 28 | + NumberParseInt, | ||
| 28 | 29 | ObjectDefineProperties, | |
| 29 | 30 | ObjectSetPrototypeOf, | |
| 30 | 31 | Set, | |
@@ -387,12 +388,12 @@ function howMuchToRead(n, state) { | |||
| 387 | 388 | // You can override either this method, or the async _read(n) below. | |
| 388 | 389 | Readable.prototype.read = function(n) { | |
| 389 | 390 | debug('read', n); | |
| 390 | - // Same as parseInt(undefined, 10), however V8 7.3 performance regressed | ||
| 391 | + // Same as NumberParseInt(undefined, 10), however V8 7.3 performance regressed | ||
| 391 | 392 | // in this scenario, so we are doing it manually. | |
| 392 | 393 | if (n === undefined) { | |
| 393 | 394 | n = NaN; | |
| 394 | 395 | } else if (!NumberIsInteger(n)) { | |
| 395 | - n = parseInt(n, 10); | ||
| 396 | + n = NumberParseInt(n, 10); | ||
| 396 | 397 | } | |
| 397 | 398 | const state = this._readableState; | |
| 398 | 399 | const nOrig = n; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | Map, | |
| 5 | + NumberParseInt, | ||
| 5 | 6 | ObjectDefineProperty, | |
| 6 | 7 | SafeWeakMap, | |
| 7 | 8 | } = primordials; | |
@@ -321,7 +322,7 @@ function setupChildProcessIpcChannel() { | |||
| 321 | 322 | if (process.env.NODE_CHANNEL_FD) { | |
| 322 | 323 | const assert = require('internal/assert'); | |
| 323 | 324 | ||
| 324 | - const fd = parseInt(process.env.NODE_CHANNEL_FD, 10); | ||
| 325 | + const fd = NumberParseInt(process.env.NODE_CHANNEL_FD, 10); | ||
| 325 | 326 | assert(fd >= 0); | |
| 326 | 327 | ||
| 327 | 328 | // Make sure it's not accidentally inherited by child processes. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | ArrayIsArray, | |
| 5 | + ArrayPrototypePush, | ||
| 6 | + NumberParseInt, | ||
| 7 | + StringPrototypeReplace, | ||
| 5 | 8 | } = primordials; | |
| 6 | 9 | ||
| 7 | 10 | const errors = require('internal/errors'); | |
@@ -78,9 +81,9 @@ class Resolver { | |||
| 78 | 81 | ipVersion = isIP(match[1]); | |
| 79 | 82 | ||
| 80 | 83 | if (ipVersion !== 0) { | |
| 81 | - const port = | ||
| 82 | - parseInt(serv.replace(addrSplitRE, '$2')) || IANA_DNS_PORT; | ||
| 83 | - return newSet.push([ipVersion, match[1], port]); | ||
| 84 | + const port = NumberParseInt( | ||
| 85 | + StringPrototypeReplace(serv, addrSplitRE, '$2')) || IANA_DNS_PORT; | ||
| 86 | + return ArrayPrototypePush(newSet, [ipVersion, match[1], port]); | ||
| 84 | 87 | } | |
| 85 | 88 | } | |
| 86 | 89 | ||
@@ -94,7 +97,8 @@ class Resolver { | |||
| 94 | 97 | ipVersion = isIP(hostIP); | |
| 95 | 98 | ||
| 96 | 99 | if (ipVersion !== 0) { | |
| 97 | - return newSet.push([ipVersion, hostIP, parseInt(port)]); | ||
| 100 | + return ArrayPrototypePush( | ||
| 101 | + newSet, [ipVersion, hostIP, NumberParseInt(port)]); | ||
| 98 | 102 | } | |
| 99 | 103 | } | |
| 100 | 104 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | const { | |
| 4 | 4 | Number, | |
| 5 | 5 | NumberIsNaN, | |
| 6 | + NumberParseInt, | ||
| 6 | 7 | ObjectCreate, | |
| 7 | 8 | } = primordials; | |
| 8 | 9 | ||
@@ -25,7 +26,7 @@ function createRepl(env, opts, cb) { | |||
| 25 | 26 | ...opts | |
| 26 | 27 | }; | |
| 27 | 28 | ||
| 28 | - if (parseInt(env.NODE_NO_READLINE)) { | ||
| 29 | + if (NumberParseInt(env.NODE_NO_READLINE)) { | ||
| 29 | 30 | opts.terminal = false; | |
| 30 | 31 | } | |
| 31 | 32 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,7 @@ const { | |||
| 29 | 29 | MathSqrt, | |
| 30 | 30 | Number, | |
| 31 | 31 | NumberIsNaN, | |
| 32 | + NumberParseInt, | ||
| 32 | 33 | NumberPrototypeValueOf, | |
| 33 | 34 | Object, | |
| 34 | 35 | ObjectAssign, | |
@@ -1950,7 +1951,8 @@ function formatWithOptionsInternal(inspectOptions, ...args) { | |||
| 1950 | 1951 | } else if (typeof tempInteger === 'symbol') { | |
| 1951 | 1952 | tempStr = 'NaN'; | |
| 1952 | 1953 | } else { | |
| 1953 | - tempStr = formatNumber(stylizeNoColor, parseInt(tempInteger)); | ||
| 1954 | + tempStr = formatNumber(stylizeNoColor, | ||
| 1955 | + NumberParseInt(tempInteger)); | ||
| 1954 | 1956 | } | |
| 1955 | 1957 | break; | |
| 1956 | 1958 | case 102: // 'f' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ const { | |||
| 5 | 5 | NumberIsInteger, | |
| 6 | 6 | NumberMAX_SAFE_INTEGER, | |
| 7 | 7 | NumberMIN_SAFE_INTEGER, | |
| 8 | + NumberParseInt, | ||
| 8 | 9 | String, | |
| 9 | 10 | } = primordials; | |
| 10 | 11 | ||
@@ -66,7 +67,7 @@ function parseFileMode(value, name, def) { | |||
| 66 | 67 | if (!octalReg.test(value)) { | |
| 67 | 68 | throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc); | |
| 68 | 69 | } | |
| 69 | - return parseInt(value, 8); | ||
| 70 | + return NumberParseInt(value, 8); | ||
| 70 | 71 | } | |
| 71 | 72 | ||
| 72 | 73 | throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ const { | |||
| 27 | 27 | Error, | |
| 28 | 28 | Number, | |
| 29 | 29 | NumberIsNaN, | |
| 30 | + NumberParseInt, | ||
| 30 | 31 | ObjectDefineProperty, | |
| 31 | 32 | ObjectSetPrototypeOf, | |
| 32 | 33 | Symbol, | |
@@ -1232,7 +1233,7 @@ function createServerHandle(address, port, addressType, fd, flags) { | |||
| 1232 | 1233 | } else if (port === -1 && addressType === -1) { | |
| 1233 | 1234 | handle = new Pipe(PipeConstants.SERVER); | |
| 1234 | 1235 | if (isWindows) { | |
| 1235 | - const instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES); | ||
| 1236 | + const instances = NumberParseInt(process.env.NODE_PENDING_PIPE_INSTANCES); | ||
| 1236 | 1237 | if (!NumberIsNaN(instances)) { | |
| 1237 | 1238 | handle.setPendingInstances(instances); | |
| 1238 | 1239 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | 25 | Float64Array, | |
| 26 | + NumberParseInt, | ||
| 26 | 27 | ObjectDefineProperties, | |
| 27 | 28 | SymbolToPrimitive, | |
| 28 | 29 | } = primordials; | |
@@ -179,7 +180,7 @@ function getCIDR(address, netmask, family) { | |||
| 179 | 180 | const parts = netmask.split(split); | |
| 180 | 181 | for (var i = 0; i < parts.length; i++) { | |
| 181 | 182 | if (parts[i] !== '') { | |
| 182 | - const binary = parseInt(parts[i], range); | ||
| 183 | + const binary = NumberParseInt(parts[i], range); | ||
| 183 | 184 | const tmp = countBinaryOnes(binary); | |
| 184 | 185 | ones += tmp; | |
| 185 | 186 | if (hasZeros) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments