mirror of https://github.com/nodejs/node.git
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."
|
message: "Use `const { RegExp } = primordials;` instead of the global."
|
||||||
- name: Set
|
- name: Set
|
||||||
message: "Use `const { Set } = primordials;` instead of the global."
|
message: "Use `const { Set } = primordials;` instead of the global."
|
||||||
|
- name: String
|
||||||
|
message: "Use `const { String } = primordials;` instead of the global."
|
||||||
- name: Symbol
|
- name: Symbol
|
||||||
message: "Use `const { Symbol } = primordials;` instead of the global."
|
message: "Use `const { Symbol } = primordials;` instead of the global."
|
||||||
- name: Uint16Array
|
- name: Uint16Array
|
||||||
|
|
|
@ -29,6 +29,7 @@ const {
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
|
String,
|
||||||
Symbol
|
Symbol
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ const {
|
||||||
Map,
|
Map,
|
||||||
NumberIsNaN,
|
NumberIsNaN,
|
||||||
RegExpPrototypeTest,
|
RegExpPrototypeTest,
|
||||||
|
String,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
|
|
|
@ -35,6 +35,7 @@ const {
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
ReflectApply,
|
ReflectApply,
|
||||||
ReflectOwnKeys,
|
ReflectOwnKeys,
|
||||||
|
String,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
SymbolAsyncIterator
|
SymbolAsyncIterator
|
||||||
|
|
|
@ -7,6 +7,7 @@ const {
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectGetPrototypeOf,
|
ObjectGetPrototypeOf,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
|
String,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const { inspect } = require('internal/util/inspect');
|
const { inspect } = require('internal/util/inspect');
|
||||||
|
|
|
@ -52,6 +52,7 @@ const {
|
||||||
ObjectPrototypeHasOwnProperty,
|
ObjectPrototypeHasOwnProperty,
|
||||||
ReflectGet,
|
ReflectGet,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
|
String,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
// Set up process.moduleLoadList.
|
// Set up process.moduleLoadList.
|
||||||
|
|
|
@ -21,6 +21,7 @@ const {
|
||||||
NumberIsInteger,
|
NumberIsInteger,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
|
String,
|
||||||
StringPrototypeStartsWith,
|
StringPrototypeStartsWith,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
|
|
|
@ -9,6 +9,7 @@ const {
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
|
String,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
SymbolToStringTag,
|
SymbolToStringTag,
|
||||||
|
|
|
@ -8,6 +8,8 @@ const {
|
||||||
ObjectCreate,
|
ObjectCreate,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
Set,
|
Set,
|
||||||
|
String,
|
||||||
|
StringFromCharCode,
|
||||||
StringPrototypeToLowerCase,
|
StringPrototypeToLowerCase,
|
||||||
Symbol,
|
Symbol,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
@ -459,8 +461,8 @@ const assertValidPseudoHeaderTrailer = hideStackFrames((key) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const emptyArray = [];
|
const emptyArray = [];
|
||||||
const kNeverIndexFlag = String.fromCharCode(NGHTTP2_NV_FLAG_NO_INDEX);
|
const kNeverIndexFlag = StringFromCharCode(NGHTTP2_NV_FLAG_NO_INDEX);
|
||||||
const kNoHeaderFlags = String.fromCharCode(NGHTTP2_NV_FLAG_NONE);
|
const kNoHeaderFlags = StringFromCharCode(NGHTTP2_NV_FLAG_NONE);
|
||||||
function mapToHeaders(map,
|
function mapToHeaders(map,
|
||||||
assertValuePseudoHeader = assertValidPseudoHeader) {
|
assertValuePseudoHeader = assertValidPseudoHeader) {
|
||||||
let ret = '';
|
let ret = '';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
Error,
|
Error,
|
||||||
|
String,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
String,
|
||||||
Symbol,
|
Symbol,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ const {
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ReflectGetOwnPropertyDescriptor,
|
ReflectGetOwnPropertyDescriptor,
|
||||||
ReflectOwnKeys,
|
ReflectOwnKeys,
|
||||||
|
String,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
SymbolToStringTag,
|
SymbolToStringTag,
|
||||||
|
|
|
@ -49,6 +49,7 @@ const {
|
||||||
Set,
|
Set,
|
||||||
SetPrototype,
|
SetPrototype,
|
||||||
SetPrototypeValues,
|
SetPrototypeValues,
|
||||||
|
String,
|
||||||
StringPrototypeValueOf,
|
StringPrototypeValueOf,
|
||||||
SymbolPrototypeToString,
|
SymbolPrototypeToString,
|
||||||
SymbolPrototypeValueOf,
|
SymbolPrototypeValueOf,
|
||||||
|
|
|
@ -5,6 +5,7 @@ const {
|
||||||
NumberIsInteger,
|
NumberIsInteger,
|
||||||
NumberMAX_SAFE_INTEGER,
|
NumberMAX_SAFE_INTEGER,
|
||||||
NumberMIN_SAFE_INTEGER,
|
NumberMIN_SAFE_INTEGER,
|
||||||
|
String,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -11,6 +11,7 @@ const {
|
||||||
ObjectEntries,
|
ObjectEntries,
|
||||||
Promise,
|
Promise,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
|
String,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
|
@ -29,6 +29,7 @@ const {
|
||||||
MathAbs,
|
MathAbs,
|
||||||
ObjectCreate,
|
ObjectCreate,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
|
String,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
|
|
18
lib/tls.js
18
lib/tls.js
|
@ -26,6 +26,10 @@ const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectFreeze,
|
ObjectFreeze,
|
||||||
|
StringFromCharCode,
|
||||||
|
StringPrototypeCharCodeAt,
|
||||||
|
StringPrototypeReplace,
|
||||||
|
StringPrototypeSplit,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -137,11 +141,17 @@ function unfqdn(host) {
|
||||||
return host.replace(/[.]$/, '');
|
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) {
|
function splitHost(host) {
|
||||||
// String#toLowerCase() is locale-sensitive so we use
|
return StringPrototypeSplit(
|
||||||
// a conservative version that only lowercases A-Z.
|
StringPrototypeReplace(unfqdn(host), /[A-Z]/g, toLowerCase),
|
||||||
const replacer = (c) => String.fromCharCode(32 + c.charCodeAt(0));
|
'.'
|
||||||
return unfqdn(host).replace(/[A-Z]/g, replacer).split('.');
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function check(hostParts, pattern, wildcards) {
|
function check(hostParts, pattern, wildcards) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ const {
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
ObjectEntries,
|
ObjectEntries,
|
||||||
|
String,
|
||||||
Symbol,
|
Symbol,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue