diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 02d70f83f9c..0f34afff081 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -49,6 +49,8 @@ rules: message: "Use `const { RegExp } = primordials;` instead of the global." - name: Set message: "Use `const { Set } = primordials;` instead of the global." + - name: String + message: "Use `const { String } = primordials;` instead of the global." - name: Symbol message: "Use `const { Symbol } = primordials;` instead of the global." - name: Uint16Array diff --git a/lib/_http_client.js b/lib/_http_client.js index 30ab9016844..0aae57aed4e 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -29,6 +29,7 @@ const { ObjectAssign, ObjectKeys, ObjectSetPrototypeOf, + String, Symbol } = primordials; diff --git a/lib/assert.js b/lib/assert.js index 6ad672d6986..08ef1824092 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -29,6 +29,7 @@ const { Map, NumberIsNaN, RegExpPrototypeTest, + String, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/events.js b/lib/events.js index c1343acbf31..7d3ee54018d 100644 --- a/lib/events.js +++ b/lib/events.js @@ -35,6 +35,7 @@ const { PromiseResolve, ReflectApply, ReflectOwnKeys, + String, Symbol, SymbolFor, SymbolAsyncIterator diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js index 3c2150c69e4..c89219eef82 100644 --- a/lib/internal/assert/assertion_error.js +++ b/lib/internal/assert/assertion_error.js @@ -7,6 +7,7 @@ const { ObjectDefineProperty, ObjectGetPrototypeOf, ObjectKeys, + String, } = primordials; const { inspect } = require('internal/util/inspect'); diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index c4ef1d12a29..127ef67c36e 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -52,6 +52,7 @@ const { ObjectPrototypeHasOwnProperty, ReflectGet, SafeSet, + String, } = primordials; // Set up process.moduleLoadList. diff --git a/lib/internal/errors.js b/lib/internal/errors.js index ff4cea13b61..314c06c7b78 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -21,6 +21,7 @@ const { NumberIsInteger, ObjectDefineProperty, ObjectKeys, + String, StringPrototypeStartsWith, Symbol, SymbolFor, diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index f9dda75f046..4db6af26e39 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -9,6 +9,7 @@ const { ObjectAssign, ObjectDefineProperties, ObjectDefineProperty, + String, Symbol, SymbolFor, SymbolToStringTag, diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index 93994ca29ea..b3fdf420c8c 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -8,6 +8,8 @@ const { ObjectCreate, ObjectKeys, Set, + String, + StringFromCharCode, StringPrototypeToLowerCase, Symbol, } = primordials; @@ -459,8 +461,8 @@ const assertValidPseudoHeaderTrailer = hideStackFrames((key) => { }); const emptyArray = []; -const kNeverIndexFlag = String.fromCharCode(NGHTTP2_NV_FLAG_NO_INDEX); -const kNoHeaderFlags = String.fromCharCode(NGHTTP2_NV_FLAG_NONE); +const kNeverIndexFlag = StringFromCharCode(NGHTTP2_NV_FLAG_NO_INDEX); +const kNoHeaderFlags = StringFromCharCode(NGHTTP2_NV_FLAG_NONE); function mapToHeaders(map, assertValuePseudoHeader = assertValidPseudoHeader) { let ret = ''; diff --git a/lib/internal/process/warning.js b/lib/internal/process/warning.js index e2d41eac73b..2822ef22f1f 100644 --- a/lib/internal/process/warning.js +++ b/lib/internal/process/warning.js @@ -3,6 +3,7 @@ const { ArrayIsArray, Error, + String, } = primordials; const assert = require('internal/assert'); diff --git a/lib/internal/readline/utils.js b/lib/internal/readline/utils.js index d75b64dd46b..408d12d01e1 100644 --- a/lib/internal/readline/utils.js +++ b/lib/internal/readline/utils.js @@ -1,6 +1,7 @@ 'use strict'; const { + String, Symbol, } = primordials; diff --git a/lib/internal/url.js b/lib/internal/url.js index f56e006e90a..3c464ffbd63 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -11,6 +11,7 @@ const { ObjectKeys, ReflectGetOwnPropertyDescriptor, ReflectOwnKeys, + String, Symbol, SymbolIterator, SymbolToStringTag, diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index a9795390253..2a9bb18fdf6 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -49,6 +49,7 @@ const { Set, SetPrototype, SetPrototypeValues, + String, StringPrototypeValueOf, SymbolPrototypeToString, SymbolPrototypeValueOf, diff --git a/lib/internal/validators.js b/lib/internal/validators.js index f9509a48827..2ef7d653d98 100644 --- a/lib/internal/validators.js +++ b/lib/internal/validators.js @@ -5,6 +5,7 @@ const { NumberIsInteger, NumberMAX_SAFE_INTEGER, NumberMIN_SAFE_INTEGER, + String, } = primordials; const { diff --git a/lib/internal/worker.js b/lib/internal/worker.js index c04484b3d8d..c89c8cd4e27 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -11,6 +11,7 @@ const { ObjectEntries, Promise, PromiseResolve, + String, Symbol, SymbolFor, } = primordials; diff --git a/lib/querystring.js b/lib/querystring.js index 4d196633dcf..04a21e8d07f 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -29,6 +29,7 @@ const { MathAbs, ObjectCreate, ObjectKeys, + String, } = primordials; const { Buffer } = require('buffer'); diff --git a/lib/tls.js b/lib/tls.js index 2ccbe409c96..a46031ad7da 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -26,6 +26,10 @@ const { ArrayIsArray, ObjectDefineProperty, ObjectFreeze, + StringFromCharCode, + StringPrototypeCharCodeAt, + StringPrototypeReplace, + StringPrototypeSplit, } = primordials; const { @@ -137,11 +141,17 @@ function unfqdn(host) { return host.replace(/[.]$/, ''); } +// String#toLowerCase() is locale-sensitive so we use +// a conservative version that only lowercases A-Z. +function toLowerCase(c) { + return StringFromCharCode(32 + StringPrototypeCharCodeAt(c, 0)); +} + function splitHost(host) { - // String#toLowerCase() is locale-sensitive so we use - // a conservative version that only lowercases A-Z. - const replacer = (c) => String.fromCharCode(32 + c.charCodeAt(0)); - return unfqdn(host).replace(/[A-Z]/g, replacer).split('.'); + return StringPrototypeSplit( + StringPrototypeReplace(unfqdn(host), /[A-Z]/g, toLowerCase), + '.' + ); } function check(hostParts, pattern, wildcards) { diff --git a/lib/wasi.js b/lib/wasi.js index a764a1745ab..072f19be923 100644 --- a/lib/wasi.js +++ b/lib/wasi.js @@ -4,6 +4,7 @@ const { ArrayPrototypePush, FunctionPrototypeBind, ObjectEntries, + String, Symbol, } = primordials;