mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: replace string prototype usage with alternatives
PR-URL: https://github.com/nodejs/node/pull/52440 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
@@ -5,6 +5,10 @@ const {
|
||||
getEmbedderOptions: getEmbedderOptionsFromBinding,
|
||||
} = internalBinding('options');
|
||||
|
||||
const {
|
||||
StringPrototypeSlice,
|
||||
} = primordials;
|
||||
|
||||
let warnOnAllowUnauthorized = true;
|
||||
|
||||
let optionsMap;
|
||||
@@ -43,8 +47,15 @@ function refreshOptions() {
|
||||
|
||||
function getOptionValue(optionName) {
|
||||
const options = getCLIOptionsFromBinding();
|
||||
if (optionName.startsWith('--no-')) {
|
||||
const option = options.get('--' + optionName.slice(5));
|
||||
if (
|
||||
optionName.length > 5 &&
|
||||
optionName[0] === '-' &&
|
||||
optionName[1] === '-' &&
|
||||
optionName[2] === 'n' &&
|
||||
optionName[3] === 'o' &&
|
||||
optionName[4] === '-'
|
||||
) {
|
||||
const option = options.get('--' + StringPrototypeSlice(optionName, 5));
|
||||
return option && !option.value;
|
||||
}
|
||||
return options.get(optionName)?.value;
|
||||
|
||||
Reference in New Issue
Block a user