{"ScriptPreparationCode":"var state = {\r\n flag: false,\r\n text: \u0027Default state\u0027,\r\n nested1: {\r\n flag: false,\r\n value: 1,\r\n text: \u0027Nested1\u0027,\r\n deep1: {\r\n flag: false,\r\n value: 1,\r\n text: \u0027Deep1\u0027,\r\n },\r\n deep2: {\r\n flag: false,\r\n value: 1,\r\n text: \u0027Deep2\u0027,\r\n deeper: {\r\n text: \u0027Very deep\u0027,\r\n value: 1\r\n }\r\n },\r\n },\r\n nested2: {\r\n flag: false,\r\n value: 2,\r\n text: \u0027Nested2\u0027,\r\n\t deep1: {\r\n flag: false,\r\n value: 1,\r\n text: \u0027Deep1\u0027,\r\n },\r\n deep2: {\r\n flag: false,\r\n value: 1,\r\n text: \u0027Deep2\u0027,\r\n deeper: {\r\n text: \u0027Very deep\u0027,\r\n value: 1\r\n }\r\n }, \r\n },\r\n \tnested3: {\r\n flag: false,\r\n value: 3,\r\n text: \u0027Nested3\u0027,\r\n\t deep1: {\r\n flag: false,\r\n value: 1,\r\n text: \u0027Deep1\u0027,\r\n },\r\n deep2: {\r\n flag: false,\r\n value: 1,\r\n text: \u0027Deep2\u0027,\r\n deeper: {\r\n text: \u0027Very deep\u0027,\r\n value: 1,\r\n flag: false\r\n }\r\n },\r\n },\r\n};\r\n\r\nvar patch = {\r\n flag: true,\r\n nested1: {\r\n flag: true\r\n },\r\n nested2: {\r\n deep1: {\r\n flag: true\r\n }\r\n },\r\n nested3: {\r\n deep2: {\r\n deeper: {\r\n flag: true\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction reassign(obj, src) {\r\n return _.isObjectLike(obj) ? _.assignWith(_.clone(obj), src, reassign) : _.cloneDeep(src);\r\n}\r\n\r\nvar immutableState = Immutable(state);\r\n\r\nfunction spreadMerge(state, patch) {\r\n return {\r\n ...state,\r\n flag: true,\r\n nested1: {\r\n ...state.nested1,\r\n flag: true\r\n },\r\n nested2: {\r\n ...state.nested2,\r\n deep1: {\r\n ...state.nested2.deep1,\r\n flag: true\r\n }\r\n },\r\n nested3: {\r\n ...state.nested3,\r\n deep2: {\r\n ...state.nested3.deep2,\r\n deeper: {\r\n ...state.nested3.deep2.deeper,\r\n flag: true\r\n }\r\n }\r\n }\r\n\r\n }\r\n}\r\n","TestCases":[{"Name":"Lodash simple merge","Code":"_.merge({}, state, patch)","IsDeferred":false},{"Name":"Lodash smart merge","Code":"reassign(state, patch)","IsDeferred":false},{"Name":"seamless-immutable merge","Code":"Immutable.merge(immutableState, patch, {deep: true})","IsDeferred":false},{"Name":"Spread merge","Code":"spreadMerge(state, patch)","IsDeferred":false}]}