merge.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. exports.__esModule = true;
  3. var _getIterator2 = require("babel-runtime/core-js/get-iterator");
  4. var _getIterator3 = _interopRequireDefault(_getIterator2);
  5. exports.default = function (dest, src) {
  6. if (!dest || !src) return;
  7. return (0, _mergeWith2.default)(dest, src, function (a, b) {
  8. if (b && Array.isArray(a)) {
  9. var newArray = b.slice(0);
  10. for (var _iterator = a, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
  11. var _ref;
  12. if (_isArray) {
  13. if (_i >= _iterator.length) break;
  14. _ref = _iterator[_i++];
  15. } else {
  16. _i = _iterator.next();
  17. if (_i.done) break;
  18. _ref = _i.value;
  19. }
  20. var item = _ref;
  21. if (newArray.indexOf(item) < 0) {
  22. newArray.push(item);
  23. }
  24. }
  25. return newArray;
  26. }
  27. });
  28. };
  29. var _mergeWith = require("lodash/mergeWith");
  30. var _mergeWith2 = _interopRequireDefault(_mergeWith);
  31. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32. module.exports = exports["default"];