1 | (function webpackUniversalModuleDefinition(root, factory) {
|
2 | if(typeof exports === 'object' && typeof module === 'object')
|
3 | module.exports = factory(require("lodash/lang"));
|
4 | else if(typeof define === 'function' && define.amd)
|
5 | define(["lodash/lang"], factory);
|
6 | else if(typeof exports === 'object')
|
7 | exports["merge.js"] = factory(require("lodash/lang"));
|
8 | else
|
9 | root["merge.js"] = factory(root["lodash/lang"]);
|
10 | })(this, function(__WEBPACK_EXTERNAL_MODULE_13__) {
|
11 | return (function(modules) {
|
12 |
|
13 | var installedModules = {};
|
14 |
|
15 |
|
16 | function __webpack_require__(moduleId) {
|
17 |
|
18 |
|
19 | if(installedModules[moduleId])
|
20 | return installedModules[moduleId].exports;
|
21 |
|
22 |
|
23 | var module = installedModules[moduleId] = {
|
24 | exports: {},
|
25 | id: moduleId,
|
26 | loaded: false
|
27 | };
|
28 |
|
29 |
|
30 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31 |
|
32 |
|
33 | module.loaded = true;
|
34 |
|
35 |
|
36 | return module.exports;
|
37 | }
|
38 |
|
39 |
|
40 |
|
41 | __webpack_require__.m = modules;
|
42 |
|
43 |
|
44 | __webpack_require__.c = installedModules;
|
45 |
|
46 |
|
47 | __webpack_require__.p = "";
|
48 |
|
49 |
|
50 | return __webpack_require__(0);
|
51 | })
|
52 |
|
53 | ({
|
54 |
|
55 | 0:
|
56 | function(module, exports, __webpack_require__) {
|
57 |
|
58 | 'use strict';
|
59 |
|
60 | Object.defineProperty(exports, "__esModule", {
|
61 | value: true
|
62 | });
|
63 |
|
64 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
65 |
|
66 | exports.default = merge;
|
67 |
|
68 | var _lang = __webpack_require__(13);
|
69 |
|
70 | function merge(state, stateDiff) {
|
71 | var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
72 |
|
73 | var newState = _extends({}, state);
|
74 |
|
75 | var _options$emptyDict = options.emptyDict;
|
76 | var emptyDict = _options$emptyDict === undefined ? 'strict' : _options$emptyDict;
|
77 | var _options$array = options.array;
|
78 | var array = _options$array === undefined ? 'replace' : _options$array;
|
79 |
|
80 |
|
81 | Object.keys(stateDiff).forEach(function (key) {
|
82 | var oldVal = newState[key];
|
83 | var newVal = stateDiff[key];
|
84 | var newValIsEmpty = (0, _lang.isEmpty)(newVal);
|
85 |
|
86 | if ((0, _lang.isPlainObject)(oldVal) && (0, _lang.isPlainObject)(newVal)) {
|
87 | if (newValIsEmpty && emptyDict === 'skip') {
|
88 | newState[key] = oldVal;
|
89 | } else if (newValIsEmpty && emptyDict === 'replace') {
|
90 | newState[key] = newVal;
|
91 | } else {
|
92 | newState[key] = merge(oldVal, newVal);
|
93 | }
|
94 | } else if (Array.isArray(oldVal) && Array.isArray(newVal)) {
|
95 | if (array === 'concat') {
|
96 | newState[key] = oldVal.concat(newVal);
|
97 | } else {
|
98 | newState[key] = newVal;
|
99 | }
|
100 | } else {
|
101 | newState[key] = newVal;
|
102 | }
|
103 | });
|
104 |
|
105 | return newState;
|
106 | }
|
107 |
|
108 | },
|
109 |
|
110 | 13:
|
111 | function(module, exports) {
|
112 |
|
113 | module.exports = require("lodash/lang");
|
114 |
|
115 | }
|
116 |
|
117 | })
|
118 | });
|
119 | ; |
\ | No newline at end of file |