Skip to content

Commit

Permalink
lib: simplify options lazy-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
avivkeller committed Sep 21, 2024
1 parent 8b8fc53 commit c7f59bd
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions lib/internal/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,23 @@ let embedderOptions;
// complete so that we don't accidentally include runtime-dependent
// states into a runtime-independent snapshot.
function getCLIOptionsFromBinding() {
if (!optionsDict) {
optionsDict = getCLIOptionsValues();
}
return optionsDict;
return optionsDict ??= getCLIOptionsValues();
}

function getCLIOptionsInfoFromBinding() {
if (!cliInfo) {
cliInfo = getCLIOptionsInfo();
}
return cliInfo;
return cliInfo ??= getCLIOptionsInfo();
}

function getEmbedderOptions() {
if (!embedderOptions) {
embedderOptions = getEmbedderOptionsFromBinding();
}
return embedderOptions;
return embedderOptions ??= getEmbedderOptionsFromBinding();
}

function refreshOptions() {
optionsDict = undefined;
}

function getOptionValue(optionName) {
const optionsDict = getCLIOptionsFromBinding();
return optionsDict[optionName];
return getCLIOptionsFromBinding()[optionName];
}

function getAllowUnauthorized() {
Expand Down

0 comments on commit c7f59bd

Please sign in to comment.