MCPcopy
hub / github.com/webpack/webpack / combineSizes

Function combineSizes

lib/optimize/SplitChunksPlugin.js:368–382  ·  view source on GitHub ↗
(a, b, combine)

Source from the content-addressed store, hash-verified

366 * @returns {SplitChunksSizes} the combine sizes
367 */
368const combineSizes = (a, b, combine) => {
369 const aKeys = /** @type {Set<SourceType>} */ (new Set(Object.keys(a)));
370 const bKeys = /** @type {Set<SourceType>} */ (new Set(Object.keys(b)));
371 /** @type {SplitChunksSizes} */
372 const result = {};
373 for (const key of aKeys) {
374 result[key] = bKeys.has(key) ? combine(a[key], b[key]) : a[key];
375 }
376 for (const key of bKeys) {
377 if (!aKeys.has(key)) {
378 result[key] = b[key];
379 }
380 }
381 return result;
382};
383
384/**
385 * Checks true if there are sizes and all existing sizes are at least minSize.

Callers 1

applyMethod · 0.85

Calls 3

keysMethod · 0.65
combineFunction · 0.50
hasMethod · 0.45

Tested by

no test coverage detected