Skip to content

Commit c7f59bd

Browse files
committed
lib: simplify options lazy-loading
1 parent 8b8fc53 commit c7f59bd

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

lib/internal/options.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,23 @@ let embedderOptions;
1717
// complete so that we don't accidentally include runtime-dependent
1818
// states into a runtime-independent snapshot.
1919
function getCLIOptionsFromBinding() {
20-
if (!optionsDict) {
21-
optionsDict = getCLIOptionsValues();
22-
}
23-
return optionsDict;
20+
return optionsDict ??= getCLIOptionsValues();
2421
}
2522

2623
function getCLIOptionsInfoFromBinding() {
27-
if (!cliInfo) {
28-
cliInfo = getCLIOptionsInfo();
29-
}
30-
return cliInfo;
24+
return cliInfo ??= getCLIOptionsInfo();
3125
}
3226

3327
function getEmbedderOptions() {
34-
if (!embedderOptions) {
35-
embedderOptions = getEmbedderOptionsFromBinding();
36-
}
37-
return embedderOptions;
28+
return embedderOptions ??= getEmbedderOptionsFromBinding();
3829
}
3930

4031
function refreshOptions() {
4132
optionsDict = undefined;
4233
}
4334

4435
function getOptionValue(optionName) {
45-
const optionsDict = getCLIOptionsFromBinding();
46-
return optionsDict[optionName];
36+
return getCLIOptionsFromBinding()[optionName];
4737
}
4838

4939
function getAllowUnauthorized() {

0 commit comments

Comments
 (0)