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

Method _queue

benchmark/common.js:131–178  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

129 }
130
131 _queue(options) {
132 const queue = [];
133 const keys = Object.keys(options);
134 const { combinationFilter } = this;
135
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, {});
173 } else {
174 queue.push({});
175 }
176
177 return queue;
178 }
179
180 http(options, cb) {
181 const http_options = { ...options };

Callers 1

constructorMethod · 0.95

Calls 3

keysMethod · 0.65
recursiveFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected