MCPcopy
hub / github.com/webpack/webpack / mergeRuntime

Function mergeRuntime

lib/util/runtime.js:202–236  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

200 * @returns {RuntimeSpec} merged
201 */
202const mergeRuntime = (a, b) => {
203 if (a === undefined) {
204 return b;
205 } else if (b === undefined) {
206 return a;
207 } else if (a === b) {
208 return a;
209 } else if (typeof a === "string") {
210 if (typeof b === "string") {
211 /** @type {RuntimeSpecSortableSet} */
212 const set = new SortableSet();
213 set.add(a);
214 set.add(b);
215 return set;
216 } else if (b.has(a)) {
217 return b;
218 }
219 /** @type {RuntimeSpecSortableSet} */
220 const set = new SortableSet(b);
221 set.add(a);
222 return set;
223 }
224 if (typeof b === "string") {
225 if (a.has(b)) return a;
226 /** @type {RuntimeSpecSortableSet} */
227 const set = new SortableSet(a);
228 set.add(b);
229 return set;
230 }
231 /** @type {RuntimeSpecSortableSet} */
232 const set = new SortableSet(a);
233 for (const item of b) set.add(item);
234 if (set.size === a.size) return a;
235 return set;
236};
237
238/**
239 * Merges runtime condition.

Callers 9

processConnectQueueFunction · 0.85
buildChunkGraphFunction · 0.85
mergeMethod · 0.85
splitMethod · 0.85
integrateChunksMethod · 0.85
_tryToAddMethod · 0.85
applyMethod · 0.85
mergeRuntimeConditionFunction · 0.85

Calls 2

addMethod · 0.95
hasMethod · 0.45

Tested by

no test coverage detected