MCPcopy
hub / github.com/tdewolff/minify / mappingByIndex

Function mappingByIndex

_benchmarks/sample_echarts.js:7448–7484  ·  view source on GitHub ↗
(result, newCmptOptions, brandNew)

Source from the content-addressed store, hash-verified

7446 }
7447
7448 function mappingByIndex(result, newCmptOptions, brandNew) {
7449 each(newCmptOptions, function (cmptOption) {
7450 if (!cmptOption) {
7451 return;
7452 } // Find the first place that not mapped by id and not internal component (consider the "hole").
7453
7454
7455 var resultItem;
7456 var nextIdx = 0;
7457
7458 while ( // Be `!resultItem` only when `nextIdx >= result.length`.
7459 (resultItem = result[nextIdx]) && ( // (1) Existing models that already have id should be able to mapped to. Because
7460 // after mapping performed, model will always be assigned with an id if user not given.
7461 // After that all models have id.
7462 // (2) If new option has id, it can only set to a hole or append to the last. It should
7463 // not be merged to the existings with different id. Because id should not be overwritten.
7464 // (3) Name can be overwritten, because axis use name as 'show label text'.
7465 resultItem.newOption || isComponentIdInternal(resultItem.existing) || // In mode "replaceMerge", here no not-mapped-non-internal-existing.
7466 resultItem.existing && cmptOption.id != null && !keyExistAndEqual('id', cmptOption, resultItem.existing))) {
7467 nextIdx++;
7468 }
7469
7470 if (resultItem) {
7471 resultItem.newOption = cmptOption;
7472 resultItem.brandNew = brandNew;
7473 } else {
7474 result.push({
7475 newOption: cmptOption,
7476 brandNew: brandNew,
7477 existing: null,
7478 keyInfo: null
7479 });
7480 }
7481
7482 nextIdx++;
7483 });
7484 }
7485
7486 function mappingInReplaceAllMode(result, newCmptOptions) {
7487 each(newCmptOptions, function (cmptOption) {

Callers 1

mappingToExistsFunction · 0.85

Calls 3

isComponentIdInternalFunction · 0.85
keyExistAndEqualFunction · 0.85
eachFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…