Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export var merge = function merge(source, other) {
if (!isObject(source) || !isObject(other)) {
return other === undefined ? source : other;
}
if (isFunction(source) || isFunction(other)) {
return other === undefined ? source : other;
} // 合并两个对象的 key,另外要区分数组的初始值为 []
var keys = _Object$keys(_objectSpread({}, source, {}, other));
return _reduceInstanceProperty(keys).call(keys, function (acc, key) {
// 递归合并 value
acc[key] = merge(source[key], other[key]);
return acc;
}, _Array$isArray(source) ? [] : {});
};
/**
return 'second argument detail required object';
} // 字端段类型校验
if (_typeof(extra) !== 'object') {
return 'third argument extra required object';
} // 字段校验
var ruleItem = rule[code];
if (ruleItem) {
// 消费字段必填
var requireFields = _toConsumableArray(ruleItem.df);
var realFields = _Object$keys(detail);
var needFields = [];
_forEachInstanceProperty(requireFields).call(requireFields, function (field) {
// 缺字端
if (_indexOfInstanceProperty(realFields).call(realFields, field) === -1) {
needFields.push(field);
}
});
if (needFields.length) {
var _context2;
return _concatInstanceProperty(_context2 = "code: ".concat(code, " \u8981\u6C42 ")).call(_context2, needFields.join(','), "\u5B57\u6BB5\u5FC5\u586B");
}
}
var detail = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var dbDetail = {
error_no: '',
http_code: '',
during_ms: '',
url: '',
request_size_b: '',
response_size_b: ''
}; // 查找rule
var ruleItem = rule[code];
if (ruleItem) {
var d = _objectSpread({}, dbDetail);
var fields = _Object$keys(detail);
_forEachInstanceProperty(fields).call(fields, function (field) {
var transferField = ruleItem.dft[field]; // 需要字段转换
if (transferField) {
// 需要字段转换
d[transferField] = detail[field];
delete detail[field];
} else {
d[field] = detail[field];
}
});
return d;
} else {
return detail;