mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
lib: replace String global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Pranshu Srivastava <rexagod@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
This commit is contained in:
parent
693cc2c1c3
commit
b79829c5f5
@ -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
|
||||
|
@ -29,6 +29,7 @@ const {
|
||||
ObjectAssign,
|
||||
ObjectKeys,
|
||||
ObjectSetPrototypeOf,
|
||||
String,
|
||||
Symbol
|
||||
} = primordials;
|
||||
|
||||
|
@ -29,6 +29,7 @@ const {
|
||||
Map,
|
||||
NumberIsNaN,
|
||||
RegExpPrototypeTest,
|
||||
String,
|
||||
} = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
|
@ -35,6 +35,7 @@ const {
|
||||
PromiseResolve,
|
||||
ReflectApply,
|
||||
ReflectOwnKeys,
|
||||
String,
|
||||
Symbol,
|
||||
SymbolFor,
|
||||
SymbolAsyncIterator
|
||||
|
@ -7,6 +7,7 @@ const {
|
||||
ObjectDefineProperty,
|
||||
ObjectGetPrototypeOf,
|
||||
ObjectKeys,
|
||||
String,
|
||||
} = primordials;
|
||||
|
||||
const { inspect } = require('internal/util/inspect');
|
||||
|
@ -52,6 +52,7 @@ const {
|
||||
ObjectPrototypeHasOwnProperty,
|
||||
ReflectGet,
|
||||
SafeSet,
|
||||
String,
|
||||
} = primordials;
|
||||
|
||||
// Set up process.moduleLoadList.
|
||||
|
@ -21,6 +21,7 @@ const {
|
||||
NumberIsInteger,
|
||||
ObjectDefineProperty,
|
||||
ObjectKeys,
|
||||
String,
|
||||
StringPrototypeStartsWith,
|
||||
Symbol,
|
||||
SymbolFor,
|
||||
|
@ -9,6 +9,7 @@ const {
|
||||
ObjectAssign,
|
||||
ObjectDefineProperties,
|
||||
ObjectDefineProperty,
|
||||
String,
|
||||
Symbol,
|
||||
SymbolFor,
|
||||
SymbolToStringTag,
|
||||
|
@ -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 = '';
|
||||
|
@ -3,6 +3,7 @@
|
||||
const {
|
||||
ArrayIsArray,
|
||||
Error,
|
||||
String,
|
||||
} = primordials;
|
||||
|
||||
const assert = require('internal/assert');
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
String,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
|
@ -11,6 +11,7 @@ const {
|
||||
ObjectKeys,
|
||||
ReflectGetOwnPropertyDescriptor,
|
||||
ReflectOwnKeys,
|
||||
String,
|
||||
Symbol,
|
||||
SymbolIterator,
|
||||
SymbolToStringTag,
|
||||
|
@ -49,6 +49,7 @@ const {
|
||||
Set,
|
||||
SetPrototype,
|
||||
SetPrototypeValues,
|
||||
String,
|
||||
StringPrototypeValueOf,
|
||||
SymbolPrototypeToString,
|
||||
SymbolPrototypeValueOf,
|
||||
|
@ -5,6 +5,7 @@ const {
|
||||
NumberIsInteger,
|
||||
NumberMAX_SAFE_INTEGER,
|
||||
NumberMIN_SAFE_INTEGER,
|
||||
String,
|
||||
} = primordials;
|
||||
|
||||
const {
|
||||
|
@ -11,6 +11,7 @@ const {
|
||||
ObjectEntries,
|
||||
Promise,
|
||||
PromiseResolve,
|
||||
String,
|
||||
Symbol,
|
||||
SymbolFor,
|
||||
} = primordials;
|
||||
|
@ -29,6 +29,7 @@ const {
|
||||
MathAbs,
|
||||
ObjectCreate,
|
||||
ObjectKeys,
|
||||
String,
|
||||
} = primordials;
|
||||
|
||||
const { Buffer } = require('buffer');
|
||||
|
18
lib/tls.js
18
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) {
|
||||
|
@ -4,6 +4,7 @@ const {
|
||||
ArrayPrototypePush,
|
||||
FunctionPrototypeBind,
|
||||
ObjectEntries,
|
||||
String,
|
||||
Symbol,
|
||||
} = primordials;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user