MCPcopy
hub / github.com/webpack/webpack / intersectRuntime

Function intersectRuntime

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

Source from the content-addressed store, hash-verified

322 * @returns {RuntimeSpec} merged
323 */
324const intersectRuntime = (a, b) => {
325 if (a === undefined) {
326 return b;
327 } else if (b === undefined) {
328 return a;
329 } else if (a === b) {
330 return a;
331 } else if (typeof a === "string") {
332 if (typeof b === "string") {
333 return;
334 } else if (b.has(a)) {
335 return a;
336 }
337 return;
338 }
339 if (typeof b === "string") {
340 if (a.has(b)) return b;
341 return;
342 }
343 /** @type {RuntimeSpecSortableSet} */
344 const set = new SortableSet();
345 for (const item of b) {
346 if (a.has(item)) set.add(item);
347 }
348 if (set.size === 0) return;
349 if (set.size === 1) {
350 const [item] = set;
351 return item;
352 }
353 return set;
354};
355
356/**
357 * Returns result.

Callers 5

applyMethod · 0.85
_tryToAddMethod · 0.85
codeGenerationMethod · 0.85
updateHashMethod · 0.85
renderBootstrapMethod · 0.85

Calls 2

addMethod · 0.95
hasMethod · 0.45

Tested by

no test coverage detected