| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5f51729 commit f17dde8
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,32 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { getOptions, shouldNotRegisterESMLoader } = internalBinding('options'); | |
| 4 | - const { options, aliases } = getOptions(); | ||
| 5 | 4 | ||
| 6 | 5 | let warnOnAllowUnauthorized = true; | |
| 7 | 6 | ||
| 7 | + let optionsMap; | ||
| 8 | + let aliasesMap; | ||
| 9 | + | ||
| 10 | + // getOptions() would serialize the option values from C++ land. | ||
| 11 | + // It would error if the values are queried before bootstrap is | ||
| 12 | + // complete so that we don't accidentally include runtime-dependent | ||
| 13 | + // states into a runtime-independent snapshot. | ||
| 14 | + function getOptionsFromBinding() { | ||
| 15 | + if (!optionsMap) { | ||
| 16 | + ({ options: optionsMap } = getOptions()); | ||
| 17 | + } | ||
| 18 | + return optionsMap; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + function getAliasesFromBinding() { | ||
| 22 | + if (!aliasesMap) { | ||
| 23 | + ({ aliases: aliasesMap } = getOptions()); | ||
| 24 | + } | ||
| 25 | + return aliasesMap; | ||
| 26 | + } | ||
| 27 | + | ||
| 8 | 28 | function getOptionValue(option) { | |
| 9 | - return options.get(option)?.value; | ||
| 29 | + return getOptionsFromBinding().get(option)?.value; | ||
| 10 | 30 | } | |
| 11 | 31 | ||
| 12 | 32 | function getAllowUnauthorized() { | |
@@ -24,8 +44,12 @@ function getAllowUnauthorized() { | |||
| 24 | 44 | } | |
| 25 | 45 | ||
| 26 | 46 | module.exports = { | |
| 27 | - options, | ||
| 28 | - aliases, | ||
| 47 | + get options() { | ||
| 48 | + return getOptionsFromBinding(); | ||
| 49 | + }, | ||
| 50 | + get aliases() { | ||
| 51 | + return getAliasesFromBinding(); | ||
| 52 | + }, | ||
| 29 | 53 | getOptionValue, | |
| 30 | 54 | getAllowUnauthorized, | |
| 31 | 55 | shouldNotRegisterESMLoader | |
| Back | FazBrowse Home | New Git URL |
0 commit comments