Skip to content

Commit

Permalink
lib: replace string prototype usage with alternatives
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
RedYetiDev authored and marco-ippolito committed May 2, 2024
1 parent 5040c3d commit 3eae9aa
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/internal/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const {
getEmbedderOptions: getEmbedderOptionsFromBinding,
} = internalBinding('options');

const {
StringPrototypeSlice,
} = primordials;

let warnOnAllowUnauthorized = true;

let optionsMap;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3eae9aa

Please sign in to comment.