function merge() { for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) { sources[_key] = arguments[_key]; } // This supports // merge([<object>] | ...<object>) // merge({ customizeArray: <fn>, customizeObject: <fn>})([<object>] | ...<object>) // where fn = (a, b, key) if (sources.length === 1) { if (Array.isArray(sources[0])) { return _mergeWith3.default.apply(undefined, [{}].concat(_toConsumableArray(sources[0]), [(0, _joinArrays2.default)(sources [0])])); } if (sources[0].customizeArray || sources[0].customizeObject) { return function () { for (var _len2 = arguments.length, structures = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { structures[_key2] = arguments[_key2]; } if (Array.isArray(structures[0])) { return _mergeWith3.default.apply(undefined, [{}].concat(_toConsumableArray(structures[0]), [(0, _joinArrays2.default)( sources[0])])); } return _mergeWith3.default.apply(undefined, [{}].concat(structures, [(0, _joinArrays2.default)(sources[0])])); }; } return sources[0]; } return _mergeWith3.default.apply(undefined, [{}].concat(sources, [(0, _joinArrays2.default)()])); }
n/a
function mergeMultiple() { for (var _len3 = arguments.length, sources = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { sources[_key3] = arguments[_key3]; } return (0, _values3.default)(merge(sources)); }
n/a
smart = function () { for (var _len2 = arguments.length, structures = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { structures[_key2] = arguments[_key2]; } if (Array.isArray(structures[0])) { return _mergeWith3.default.apply(undefined, [{}].concat(_toConsumableArray(structures[0]), [(0, _joinArrays2.default)(sources [0])])); } return _mergeWith3.default.apply(undefined, [{}].concat(structures, [(0, _joinArrays2.default)(sources[0])])); }
n/a
function mergeSmartStrategy() { var rules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return merge({ customizeArray: function customizeArray(a, b, key) { var topKey = key.split('.').slice(-1)[0]; if (isRule(topKey)) { switch (rules[key]) { case 'prepend': return [].concat(_toConsumableArray((0, _differenceWith3.default)(b, a, function (newRule, seenRule) { return (0, _joinArraysSmart.uniteRules)(rules, key, newRule, seenRule, 'prepend'); })), _toConsumableArray(a)); case 'replace': return b; default: // append return (0, _unionWith3.default)(a, b, _joinArraysSmart.uniteRules.bind(null, rules, key)); } } return _customizeArray(rules)(a, b, key); }, customizeObject: customizeObject(rules) }); }
n/a
function mergeStrategy() { var rules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return merge({ customizeArray: _customizeArray(rules), customizeObject: customizeObject(rules) }); }
n/a
function mergeUnique(key, uniques) { var getter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (a) { return a; }; return function (a, b, k) { return k === key && [].concat(_toConsumableArray(a), _toConsumableArray((0, _differenceWith3.default)(b, a, function (item) { return uniques.indexOf(getter(item)) >= 0; }))); }; }
n/a
function joinArrays() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, customizeArray = _ref.customizeArray, customizeObject = _ref.customizeObject, key = _ref.key; return function _joinArrays(a, b, k) { var newKey = key ? key + '.' + k : k; if ((0, _isFunction3.default)(a) && (0, _isFunction3.default)(b)) { return function () { return _joinArrays(a.apply(undefined, arguments), b.apply(undefined, arguments), k); }; } if (isArray(a) && isArray(b)) { var customResult = customizeArray && customizeArray(a, b, newKey); return customResult || [].concat(_toConsumableArray(a), _toConsumableArray(b)); } if ((0, _isPlainObject3.default)(a) && (0, _isPlainObject3.default)(b)) { var _customResult = customizeObject && customizeObject(a, b, newKey); return _customResult || (0, _mergeWith3.default)({}, a, b, joinArrays({ customizeArray: customizeArray, customizeObject: customizeObject, key: newKey })); } if ((0, _isPlainObject3.default)(b)) { return (0, _cloneDeep3.default)(b); } return b; }; }
n/a
function uniteEntries(newEntry, entry) { var loaderNameRe = /^([^?]+)/ig; var _entry$loader$match = entry.loader.match(loaderNameRe), _entry$loader$match2 = _slicedToArray(_entry$loader$match, 1), loaderName = _entry$loader$match2[0]; var _newEntry$loader$matc = newEntry.loader.match(loaderNameRe), _newEntry$loader$matc2 = _slicedToArray(_newEntry$loader$matc, 1), newLoaderName = _newEntry$loader$matc2[0]; if (loaderName !== newLoaderName) { return false; } // Replace query values with newer ones (0, _mergeWith3.default)(entry, newEntry); return true; }
n/a
function uniteRules(rules, key, newRule, rule) { if (String(rule.test) !== String(newRule.test) || (newRule.enforce || rule.enforce) && rule.enforce !== newRule.enforce || newRule .include && !isSameValue(rule.include, newRule.include) || newRule.exclude && !isSameValue(rule.exclude, newRule.exclude)) { return false; } else if (!rule.test && !rule.include && !rule.exclude && (rule.loader && rule.loader.split('?')[0]) !== (newRule.loader && newRule .loader.split('?')[0])) { // Don't merge the rule if there isn't any identifying fields and the loaders don't match return false; } else if ((rule.include || rule.exclude) && !newRule.include && !newRule.exclude) { // Don't merge child without include/exclude to parent that has either return false; } // newRule.loader should always override if (newRule.loader) { var optionsKey = newRule.options ? 'options' : newRule.query && 'query'; delete rule.use; delete rule.loaders; rule.loader = newRule.loader; if (optionsKey) { rule[optionsKey] = newRule[optionsKey]; } } else if ((rule.use || rule.loaders || rule.loader) && (newRule.use || newRule.loaders)) { var expandEntry = function expandEntry(loader) { return typeof loader === 'string' ? { loader: loader } : loader; }; // this is only here to avoid breaking existing tests var unwrapEntry = function unwrapEntry(entry) { return !entry.options && !entry.query ? entry.loader : entry; }; var entries = void 0; if (rule.loader) { var _optionsKey = rule.options ? 'options' : rule.query && 'query'; entries = [{ loader: rule.loader }]; if (_optionsKey) { entries[0][_optionsKey] = rule[_optionsKey]; } delete rule.loader; if (_optionsKey) { delete rule[_optionsKey]; } } else { entries = [].concat(rule.use || rule.loaders).map(expandEntry); } var newEntries = [].concat(newRule.use || newRule.loaders).map(expandEntry); var loadersKey = rule.use || newRule.use ? 'use' : 'loaders'; var resolvedKey = key + '.' + loadersKey; switch (rules[resolvedKey]) { case 'prepend': rule[loadersKey] = [].concat(_toConsumableArray((0, _differenceWith3.default)(newEntries, entries, uniteEntries)), _toConsumableArray (entries)).map(unwrapEntry); break; case 'replace': rule[loadersKey] = newRule.use || newRule.loaders; break; default: rule[loadersKey] = (0, _unionWith3.default)( // Remove existing entries so that we can respect the order of the new // entries (0, _differenceWith3.default)(entries, newEntries, _isEqual3.default), newEntries, uniteEntries).map(unwrapEntry); } } if (newRule.include) { rule.include = newRule.include; } if (newRule.exclude) { rule.exclude = newRule.exclude; } return true; }
n/a
function mergeUnique(key, uniques) { var getter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (a) { return a; }; return function (a, b, k) { return k === key && [].concat(_toConsumableArray(a), _toConsumableArray((0, _differenceWith3.default)(b, a, function (item) { return uniques.indexOf(getter(item)) >= 0; }))); }; }
n/a