From de9118b8706141eb81ccb837bfbca04a481f02b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 28 Sep 2020 15:57:45 +0200 Subject: [PATCH 1/7] errors: support possible deletion of globalThis.Error Do not crash trying to access prepareStackTrace on `undefined`. --- lib/internal/errors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 314c06c7b78f03..9c5087cf1d2fe0 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -81,7 +81,7 @@ const maybeOverridePrepareStackTrace = (globalThis, error, trace) => { // https://crbug.com/v8/7848 // `globalThis` is the global that contains the constructor which // created `error`. - if (typeof globalThis.Error.prepareStackTrace === 'function') { + if (typeof globalThis.Error?.prepareStackTrace === 'function') { return globalThis.Error.prepareStackTrace(error, trace); } // We still have legacy usage that depends on the main context's `Error` From 5d6751b61f23deafb03e625e3a5bbf6ce1f00279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 28 Sep 2020 16:35:42 +0200 Subject: [PATCH 2/7] lib: use global Error constructors from primordials --- lib/.eslintrc.yaml | 12 ++++++++++++ lib/internal/bootstrap/loaders.js | 1 + lib/internal/error_serdes.js | 6 ++++++ lib/internal/errors.js | 4 ++++ lib/internal/per_context/domexception.js | 1 + lib/internal/per_context/primordials.js | 6 ++++++ lib/internal/vm/module.js | 1 + lib/repl.js | 4 +++- 8 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 0f34afff0814a6..e82897d076748a 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -21,6 +21,8 @@ rules: message: "Use `const { Boolean } = primordials;` instead of the global." - name: Error message: "Use `const { Error } = primordials;` instead of the global." + - name: EvalError + message: "Use `const { EvalError } = primordials;` instead of the global." - name: Float32Array message: "Use `const { Float32Array } = primordials;` instead of the global." - name: Float64Array @@ -43,6 +45,10 @@ rules: message: "Use `const { Object } = primordials;` instead of the global." - name: Promise message: "Use `const { Promise } = primordials;` instead of the global." + - name: RangeError + message: "Use `const { RangeError } = primordials;` instead of the global." + - name: ReferenceError + message: "Use `const { ReferenceError } = primordials;` instead of the global." - name: Reflect message: "Use `const { Reflect } = primordials;` instead of the global." - name: RegExp @@ -53,6 +59,12 @@ rules: message: "Use `const { String } = primordials;` instead of the global." - name: Symbol message: "Use `const { Symbol } = primordials;` instead of the global." + - name: SyntaxError + message: "Use `const { SyntaxError } = primordials;` instead of the global." + - name: TypeError + message: "Use `const { TypeError } = primordials;` instead of the global." + - name: URIError + message: "Use `const { URIError } = primordials;` instead of the global." - name: Uint16Array message: "Use `const { Uint16Array } = primordials;` instead of the global." - name: WeakMap diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 127ef67c36eb64..d5715aa9f8c666 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -53,6 +53,7 @@ const { ReflectGet, SafeSet, String, + TypeError, } = primordials; // Set up process.moduleLoadList. diff --git a/lib/internal/error_serdes.js b/lib/internal/error_serdes.js index 5e18448da7046c..47392752df6318 100644 --- a/lib/internal/error_serdes.js +++ b/lib/internal/error_serdes.js @@ -4,6 +4,7 @@ const Buffer = require('buffer').Buffer; const { ArrayPrototypeForEach, Error, + EvalError, FunctionPrototypeCall, ObjectAssign, ObjectCreate, @@ -13,8 +14,13 @@ const { ObjectGetPrototypeOf, ObjectKeys, ObjectPrototypeToString, + RangeError, + ReferenceError, SafeSet, SymbolToStringTag, + SyntaxError, + TypeError, + URIError, } = primordials; const kSerializedError = 0; diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 9c5087cf1d2fe0..373bf11858ae07 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -21,10 +21,14 @@ const { NumberIsInteger, ObjectDefineProperty, ObjectKeys, + RangeError, String, StringPrototypeStartsWith, Symbol, SymbolFor, + SyntaxError, + TypeError, + URIError, WeakMap, } = primordials; diff --git a/lib/internal/per_context/domexception.js b/lib/internal/per_context/domexception.js index c6d6370c5547cd..06bb3fa3053cd5 100644 --- a/lib/internal/per_context/domexception.js +++ b/lib/internal/per_context/domexception.js @@ -7,6 +7,7 @@ const { SafeWeakMap, SafeMap, SymbolToStringTag, + TypeError, } = primordials; class ERR_INVALID_THIS extends TypeError { diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js index 09bea0fc7fc523..8b1b8841c25379 100644 --- a/lib/internal/per_context/primordials.js +++ b/lib/internal/per_context/primordials.js @@ -125,6 +125,7 @@ primordials.SafePromise = makeSafe( 'Boolean', 'Date', 'Error', + 'EvalError', 'Float32Array', 'Float64Array', 'Function', @@ -134,10 +135,15 @@ primordials.SafePromise = makeSafe( 'Map', 'Number', 'Object', + 'RangeError', + 'ReferenceError', 'RegExp', 'Set', 'String', 'Symbol', + 'SyntaxError', + 'TypeError', + 'URIError', 'Uint16Array', 'Uint32Array', 'Uint8Array', diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js index d9892d520e78fe..c10433a36f6dcb 100644 --- a/lib/internal/vm/module.js +++ b/lib/internal/vm/module.js @@ -9,6 +9,7 @@ const { ObjectSetPrototypeOf, SafePromise, Symbol, + TypeError, WeakMap, } = primordials; diff --git a/lib/repl.js b/lib/repl.js index f60a49b3f49d43..6d8b98b94825c5 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -60,6 +60,8 @@ const { Set, StringPrototypeIncludes, Symbol, + SyntaxError, + SyntaxErrorPrototype, WeakSet, } = primordials; @@ -1566,7 +1568,7 @@ function defineDefaultCommands(repl) { function Recoverable(err) { this.err = err; } -ObjectSetPrototypeOf(Recoverable.prototype, SyntaxError.prototype); +ObjectSetPrototypeOf(Recoverable.prototype, SyntaxErrorPrototype); ObjectSetPrototypeOf(Recoverable, SyntaxError); module.exports = { From 99bed0138145eb362a4e67103464ff3c9ba7ab98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 28 Sep 2020 16:41:03 +0200 Subject: [PATCH 3/7] lib: use Number.parseInt from primordials --- lib/.eslintrc.yaml | 2 ++ lib/internal/bootstrap/pre_execution.js | 3 ++- lib/internal/dns/utils.js | 5 +++-- lib/internal/repl.js | 3 ++- lib/internal/streams/readable.js | 3 ++- lib/internal/util/inspect.js | 4 +++- lib/internal/validators.js | 3 ++- lib/net.js | 3 ++- lib/os.js | 3 ++- 9 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index e82897d076748a..29099193bb089e 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -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: parseInt + message: "Use `const { NumberParseInt } = primordials;` instead of the global." no-restricted-syntax: # Config copied from .eslintrc.js - error diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index dd806022cada39..005b1b46c28227 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -2,6 +2,7 @@ const { Map, + NumberParseInt, ObjectDefineProperty, SafeWeakMap, } = primordials; @@ -327,7 +328,7 @@ function setupChildProcessIpcChannel() { if (process.env.NODE_CHANNEL_FD) { const assert = require('internal/assert'); - const fd = parseInt(process.env.NODE_CHANNEL_FD, 10); + const fd = NumberParseInt(process.env.NODE_CHANNEL_FD, 10); assert(fd >= 0); // Make sure it's not accidentally inherited by child processes. diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index 9948330adcda82..98e7be66ff6e7f 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -2,6 +2,7 @@ const { ArrayIsArray, + NumberParseInt, } = primordials; const errors = require('internal/errors'); @@ -79,7 +80,7 @@ class Resolver { if (ipVersion !== 0) { const port = - parseInt(serv.replace(addrSplitRE, '$2')) || IANA_DNS_PORT; + NumberParseInt(serv.replace(addrSplitRE, '$2')) || IANA_DNS_PORT; return newSet.push([ipVersion, match[1], port]); } } @@ -94,7 +95,7 @@ class Resolver { ipVersion = isIP(hostIP); if (ipVersion !== 0) { - return newSet.push([ipVersion, hostIP, parseInt(port)]); + return newSet.push([ipVersion, hostIP, NumberParseInt(port)]); } } diff --git a/lib/internal/repl.js b/lib/internal/repl.js index 565ab049c71487..5eeb2e349031b2 100644 --- a/lib/internal/repl.js +++ b/lib/internal/repl.js @@ -3,6 +3,7 @@ const { Number, NumberIsNaN, + NumberParseInt, ObjectCreate, } = primordials; @@ -25,7 +26,7 @@ function createRepl(env, opts, cb) { ...opts }; - if (parseInt(env.NODE_NO_READLINE)) { + if (NumberParseInt(env.NODE_NO_READLINE)) { opts.terminal = false; } diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index b2a6ddfb29e9e6..275fef2c676361 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -24,6 +24,7 @@ const { NumberIsInteger, NumberIsNaN, + NumberParseInt, ObjectDefineProperties, ObjectKeys, ObjectSetPrototypeOf, @@ -388,7 +389,7 @@ Readable.prototype.read = function(n) { if (n === undefined) { n = NaN; } else if (!NumberIsInteger(n)) { - n = parseInt(n, 10); + n = NumberParseInt(n, 10); } const state = this._readableState; const nOrig = n; diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 2a9bb18fdf6009..f4584bd84098d2 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -29,6 +29,7 @@ const { MathSqrt, Number, NumberIsNaN, + NumberParseInt, NumberPrototypeValueOf, Object, ObjectAssign, @@ -1950,7 +1951,8 @@ function formatWithOptionsInternal(inspectOptions, ...args) { } else if (typeof tempInteger === 'symbol') { tempStr = 'NaN'; } else { - tempStr = formatNumber(stylizeNoColor, parseInt(tempInteger)); + tempStr = formatNumber(stylizeNoColor, + NumberParseInt(tempInteger)); } break; case 102: // 'f' diff --git a/lib/internal/validators.js b/lib/internal/validators.js index 2ef7d653d98fba..2439342ae8a78b 100644 --- a/lib/internal/validators.js +++ b/lib/internal/validators.js @@ -5,6 +5,7 @@ const { NumberIsInteger, NumberMAX_SAFE_INTEGER, NumberMIN_SAFE_INTEGER, + NumberParseInt, String, } = primordials; @@ -65,7 +66,7 @@ function parseFileMode(value, name, def) { if (!octalReg.test(value)) { throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc); } - return parseInt(value, 8); + return NumberParseInt(value, 8); } throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc); diff --git a/lib/net.js b/lib/net.js index a699df2c849a43..b149878f6574dc 100644 --- a/lib/net.js +++ b/lib/net.js @@ -27,6 +27,7 @@ const { Error, Number, NumberIsNaN, + NumberParseInt, ObjectDefineProperty, ObjectSetPrototypeOf, Symbol, @@ -1204,7 +1205,7 @@ function createServerHandle(address, port, addressType, fd, flags) { } else if (port === -1 && addressType === -1) { handle = new Pipe(PipeConstants.SERVER); if (isWindows) { - const instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES); + const instances = NumberParseInt(process.env.NODE_PENDING_PIPE_INSTANCES); if (!NumberIsNaN(instances)) { handle.setPendingInstances(instances); } diff --git a/lib/os.js b/lib/os.js index dc0d08376f2da0..d03be051d09144 100644 --- a/lib/os.js +++ b/lib/os.js @@ -23,6 +23,7 @@ const { Float64Array, + NumberParseInt, ObjectDefineProperties, SymbolToPrimitive, } = primordials; @@ -179,7 +180,7 @@ function getCIDR(address, netmask, family) { const parts = netmask.split(split); for (var i = 0; i < parts.length; i++) { if (parts[i] !== '') { - const binary = parseInt(parts[i], range); + const binary = NumberParseInt(parts[i], range); const tmp = countBinaryOnes(binary); ones += tmp; if (hasZeros) { From fef731ccfe2f5995d229a6b3bce84808a0adc867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 28 Sep 2020 16:42:29 +0200 Subject: [PATCH 4/7] lib: use Number.parseFloat from primordials --- lib/.eslintrc.yaml | 2 ++ lib/internal/util/inspect.js | 4 +++- lib/repl.js | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 29099193bb089e..35ced9e9011016 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -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: diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index f4584bd84098d2..17768dfb53bf0c 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -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' diff --git a/lib/repl.js b/lib/repl.js index 6d8b98b94825c5..26cb08a57437df 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -46,6 +46,7 @@ const { Error, MathMax, NumberIsNaN, + NumberParseFloat, ObjectAssign, ObjectCreate, ObjectDefineProperty, @@ -768,7 +769,7 @@ function REPLServer(prompt, // display next prompt and return. if (trimmedCmd) { if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' && - NumberIsNaN(parseFloat(trimmedCmd))) { + NumberIsNaN(NumberParseFloat(trimmedCmd))) { const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); const keyword = matches && matches[1]; const rest = matches && matches[2]; From 1b7578ce4c7531711e76558cc4b641a624bfb92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 28 Sep 2020 16:56:54 +0200 Subject: [PATCH 5/7] lib: use remaining typed arrays from primordials --- lib/.eslintrc.yaml | 8 ++++++++ lib/buffer.js | 3 ++- lib/internal/buffer.js | 1 + lib/internal/child_process.js | 1 + lib/internal/encoding.js | 2 ++ lib/internal/http2/core.js | 2 ++ lib/internal/process/per_thread.js | 1 + lib/internal/streams/buffer_list.js | 1 + lib/internal/util/comparisons.js | 1 + lib/internal/util/inspect.js | 6 +++++- lib/internal/util/types.js | 3 ++- lib/internal/worker.js | 1 + lib/zlib.js | 2 ++ 13 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 35ced9e9011016..20e01898695507 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -11,6 +11,8 @@ rules: - error - name: Array message: "Use `const { Array } = primordials;` instead of the global." + - name: ArrayBuffer + message: "Use `const { ArrayBuffer } = primordials;` instead of the global." - name: BigInt message: "Use `const { BigInt } = primordials;` instead of the global." - name: BigInt64Array @@ -67,6 +69,12 @@ rules: message: "Use `const { URIError } = primordials;` instead of the global." - name: Uint16Array message: "Use `const { Uint16Array } = primordials;` instead of the global." + - name: Uint32Array + message: "Use `const { Uint32Array } = primordials;` instead of the global." + - name: Uint8Array + message: "Use `const { Uint8Array } = primordials;` instead of the global." + - name: Uint8ClampedArray + message: "Use `const { Uint8ClampedArray } = primordials;` instead of the global." - name: WeakMap message: "Use `const { WeakMap } = primordials;` instead of the global." - name: WeakSet diff --git a/lib/buffer.js b/lib/buffer.js index a921d491647258..0daf5636edad46 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -39,6 +39,7 @@ const { ObjectSetPrototypeOf, SymbolSpecies, SymbolToPrimitive, + Uint8Array, Uint8ArrayPrototype, } = primordials; @@ -387,7 +388,7 @@ function SlowBuffer(length) { return createUnsafeBuffer(length); } -ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype); +ObjectSetPrototypeOf(SlowBuffer.prototype, Uint8ArrayPrototype); ObjectSetPrototypeOf(SlowBuffer, Uint8Array); function allocate(size) { diff --git a/lib/internal/buffer.js b/lib/internal/buffer.js index 5b2a4a508d14e5..e23896eac93fba 100644 --- a/lib/internal/buffer.js +++ b/lib/internal/buffer.js @@ -6,6 +6,7 @@ const { Float64Array, MathFloor, Number, + Uint8Array, } = primordials; const { diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 31d9f02df36fce..092922f956a17c 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -5,6 +5,7 @@ const { ObjectDefineProperty, ObjectSetPrototypeOf, Symbol, + Uint8Array, } = primordials; const { diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index de0a1b7cc799bb..5226bf518dac38 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -10,6 +10,8 @@ const { ObjectGetOwnPropertyDescriptors, Symbol, SymbolToStringTag, + Uint32Array, + Uint8Array, } = primordials; const { diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index b913b3b5bdefbe..ab961c059187af 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -16,6 +16,8 @@ const { ReflectGetPrototypeOf, Set, Symbol, + Uint32Array, + Uint8Array, } = primordials; const { diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 1005d841a283f4..80bda3df9ace37 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -18,6 +18,7 @@ const { SetPrototype, SetPrototypeHas, StringPrototypeReplace, + Uint32Array, } = primordials; const { diff --git a/lib/internal/streams/buffer_list.js b/lib/internal/streams/buffer_list.js index fc8dd1b1f0fded..2551bee4473de4 100644 --- a/lib/internal/streams/buffer_list.js +++ b/lib/internal/streams/buffer_list.js @@ -2,6 +2,7 @@ const { SymbolIterator, + Uint8Array, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 9d4cdf9f183f16..2c10f0c8929752 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -20,6 +20,7 @@ const { StringPrototypeValueOf, SymbolPrototypeValueOf, SymbolToStringTag, + Uint8Array, } = primordials; const { compare } = internalBinding('buffer'); diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 17768dfb53bf0c..c73ab5a037fd78 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -58,6 +58,10 @@ const { SymbolIterator, SymbolToStringTag, Uint16Array, + Uint32Array, + Uint8Array, + Uint8ArrayPrototype, + Uint8ClampedArray, uncurryThis, } = primordials; @@ -138,7 +142,7 @@ const mapSizeGetter = uncurryThis( ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get); const typedArraySizeGetter = uncurryThis( ObjectGetOwnPropertyDescriptor( - ObjectGetPrototypeOf(Uint8Array.prototype), 'length').get); + ObjectGetPrototypeOf(Uint8ArrayPrototype), 'length').get); let hexSlice; diff --git a/lib/internal/util/types.js b/lib/internal/util/types.js index 676f386a2458d4..4b9eeb469b2d19 100644 --- a/lib/internal/util/types.js +++ b/lib/internal/util/types.js @@ -5,10 +5,11 @@ const { ObjectGetOwnPropertyDescriptor, ObjectGetPrototypeOf, SymbolToStringTag, + Uint8ArrayPrototype, uncurryThis, } = primordials; -const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8Array.prototype); +const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8ArrayPrototype); const TypedArrayProto_toStringTag = uncurryThis( diff --git a/lib/internal/worker.js b/lib/internal/worker.js index c89c8cd4e27b08..e97cd7efea22df 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -14,6 +14,7 @@ const { String, Symbol, SymbolFor, + Uint32Array, } = primordials; const EventEmitter = require('events'); diff --git a/lib/zlib.js b/lib/zlib.js index 1b4d3773c7f00b..faa84401e9a04b 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -22,6 +22,7 @@ 'use strict'; const { + ArrayBuffer, Error, MathMax, NumberIsFinite, @@ -33,6 +34,7 @@ const { ObjectKeys, ObjectSetPrototypeOf, Symbol, + Uint32Array, } = primordials; const { From 8100fc651f0a23a723bc3d2c13ad52ddf1bc061a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 6 Oct 2020 19:27:03 +0200 Subject: [PATCH 6/7] fixup! lib: use Number.parseInt from primordials --- lib/internal/dns/utils.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index 98e7be66ff6e7f..cee582e7fa57e9 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -2,7 +2,9 @@ const { ArrayIsArray, + ArrayPrototypePush, NumberParseInt, + StringPrototypeReplace, } = primordials; const errors = require('internal/errors'); @@ -79,9 +81,9 @@ class Resolver { ipVersion = isIP(match[1]); if (ipVersion !== 0) { - const port = - NumberParseInt(serv.replace(addrSplitRE, '$2')) || IANA_DNS_PORT; - return newSet.push([ipVersion, match[1], port]); + const port = NumberParseInt( + StringPrototypeReplace(serv, addrSplitRE, '$2')) || IANA_DNS_PORT; + return ArrayPrototypePush(newSet, [ipVersion, match[1], port]); } } @@ -95,7 +97,8 @@ class Resolver { ipVersion = isIP(hostIP); if (ipVersion !== 0) { - return newSet.push([ipVersion, hostIP, NumberParseInt(port)]); + return ArrayPrototypePush( + newSet, [ipVersion, hostIP, NumberParseInt(port)]); } } From b13dc2940f1097afa403b899ca7a5d3c09c3548b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 6 Oct 2020 19:29:23 +0200 Subject: [PATCH 7/7] fixup! lib: use Number.parseFloat from primordials --- lib/repl.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index 26cb08a57437df..78c256d60b5559 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -59,7 +59,9 @@ const { PromiseRace, RegExp, Set, + StringPrototypeCharAt, StringPrototypeIncludes, + StringPrototypeMatch, Symbol, SyntaxError, SyntaxErrorPrototype, @@ -768,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) !== '.' && + if (StringPrototypeCharAt(trimmedCmd, 0) === '.' && + StringPrototypeCharAt(trimmedCmd, 1) !== '.' && NumberIsNaN(NumberParseFloat(trimmedCmd))) { - const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); + const matches = StringPrototypeMatch(trimmedCmd, /^\.([^\s]+)\s*(.*)$/); const keyword = matches && matches[1]; const rest = matches && matches[2]; if (_parseREPLKeyword.call(self, keyword, rest) === true) {