MCPcopy Index your code
hub / github.com/nodejs/node / recursive

Method recursive

benchmark/common.js:138–169  ·  view source on GitHub ↗
(keyIndex, prevConfig)

Source from the content-addressed store, hash-verified

136 // Perform a depth-first walk through all options to generate a
137 // configuration list that contains all combinations.
138 function recursive(keyIndex, prevConfig) {
139 const key = keys[keyIndex];
140 const values = options[key];
141
142 for (const value of values) {
143 if (typeof value !== 'number' && typeof value !== 'string' && typeof value !== 'boolean') {
144 throw new TypeError(
145 `configuration "${key}" had type ${typeof value}`);
146 }
147 if (typeof value !== typeof values[0]) {
148 // This is a requirement for being able to consistently and
149 // predictably parse CLI provided configuration values.
150 throw new TypeError(`configuration "${key}" has mixed types`);
151 }
152
153 const currConfig = { [key]: value, ...prevConfig };
154
155 if (keyIndex + 1 < keys.length) {
156 recursive(keyIndex + 1, currConfig);
157 } else {
158 // Check if we should allow the current combination
159 const allowed = combinationFilter({ ...currConfig });
160 if (typeof allowed !== 'boolean') {
161 throw new TypeError(
162 'Combination filter must always return a boolean',
163 );
164 }
165 if (allowed)
166 queue.push(currConfig);
167 }
168 }
169 }
170
171 if (keys.length > 0) {
172 recursive(0, {});

Callers 1

processTopLevelAwaitFunction · 0.80

Calls 7

concatMethod · 0.80
recursiveFunction · 0.50
combinationFilterFunction · 0.50
pushMethod · 0.45
entriesMethod · 0.45
onMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected