MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / merge$$1

Function merge$$1

libs/echarts/echarts-en.simple.js:19893–19946  ·  view source on GitHub ↗
(names, hvIdx)

Source from the content-addressed store, hash-verified

19891 copy(HV_NAMES[1], targetOption, vResult);
19892
19893 function merge$$1(names, hvIdx) {
19894 var newParams = {};
19895 var newValueCount = 0;
19896 var merged = {};
19897 var mergedValueCount = 0;
19898 var enoughParamNumber = 2;
19899
19900 each$3(names, function (name) {
19901 merged[name] = targetOption[name];
19902 });
19903 each$3(names, function (name) {
19904 // Consider case: newOption.width is null, which is
19905 // set by user for removing width setting.
19906 hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
19907 hasValue(newParams, name) && newValueCount++;
19908 hasValue(merged, name) && mergedValueCount++;
19909 });
19910
19911 if (ignoreSize[hvIdx]) {
19912 // Only one of left/right is premitted to exist.
19913 if (hasValue(newOption, names[1])) {
19914 merged[names[2]] = null;
19915 }
19916 else if (hasValue(newOption, names[2])) {
19917 merged[names[1]] = null;
19918 }
19919 return merged;
19920 }
19921
19922 // Case: newOption: {width: ..., right: ...},
19923 // or targetOption: {right: ...} and newOption: {width: ...},
19924 // There is no conflict when merged only has params count
19925 // little than enoughParamNumber.
19926 if (mergedValueCount === enoughParamNumber || !newValueCount) {
19927 return merged;
19928 }
19929 // Case: newOption: {width: ..., right: ...},
19930 // Than we can make sure user only want those two, and ignore
19931 // all origin params in targetOption.
19932 else if (newValueCount >= enoughParamNumber) {
19933 return newParams;
19934 }
19935 else {
19936 // Chose another param from targetOption by priority.
19937 for (var i = 0; i < names.length; i++) {
19938 var name = names[i];
19939 if (!hasProp(newParams, name) && hasProp(targetOption, name)) {
19940 newParams[name] = targetOption[name];
19941 break;
19942 }
19943 }
19944 return newParams;
19945 }
19946 }
19947
19948 function hasProp(obj, name) {
19949 return obj.hasOwnProperty(name);

Callers 1

mergeLayoutParamFunction · 0.70

Calls 2

hasPropFunction · 0.70
hasValueFunction · 0.70

Tested by

no test coverage detected