Skip to content

Commit 64c2c2a

Browse files
avivkellermarco-ippolito
authored andcommittedMay 3, 2024
lib: replace string prototype usage with alternatives
PR-URL: #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>
1 parent 328bded commit 64c2c2a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed
 

‎lib/internal/options.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const {
55
getEmbedderOptions: getEmbedderOptionsFromBinding,
66
} = internalBinding('options');
77

8+
const {
9+
StringPrototypeSlice,
10+
} = primordials;
11+
812
let warnOnAllowUnauthorized = true;
913

1014
let optionsMap;
@@ -43,8 +47,15 @@ function refreshOptions() {
4347

4448
function getOptionValue(optionName) {
4549
const options = getCLIOptionsFromBinding();
46-
if (optionName.startsWith('--no-')) {
47-
const option = options.get('--' + optionName.slice(5));
50+
if (
51+
optionName.length > 5 &&
52+
optionName[0] === '-' &&
53+
optionName[1] === '-' &&
54+
optionName[2] === 'n' &&
55+
optionName[3] === 'o' &&
56+
optionName[4] === '-'
57+
) {
58+
const option = options.get('--' + StringPrototypeSlice(optionName, 5));
4859
return option && !option.value;
4960
}
5061
return options.get(optionName)?.value;

0 commit comments

Comments
 (0)
Please sign in to comment.