{"ScriptPreparationCode":"const JSON_PROTO = Object.getPrototypeOf({})\r\n\r\nfunction defaultIsMergeableObjectFactory () {\r\n return function defaultIsMergeableObject (value) {\r\n return typeof value === \u0027object\u0027 \u0026\u0026 value !== null \u0026\u0026 !(value instanceof RegExp) \u0026\u0026 !(value instanceof Date)\r\n }\r\n}\r\n\r\nfunction deepmergeConstructor (options) {\r\n function isNotPrototypeKey (value) {\r\n return (\r\n value !== \u0027constructor\u0027 \u0026\u0026\r\n value !== \u0027prototype\u0027 \u0026\u0026\r\n value !== \u0027__proto__\u0027\r\n )\r\n }\r\n\r\n function cloneArray (value) {\r\n let i = 0\r\n const il = value.length\r\n const result = new Array(il)\r\n for (i; i \u003C il; \u002B\u002Bi) {\r\n result[i] = clone(value[i])\r\n }\r\n return result\r\n }\r\n\r\n function cloneObject (target) {\r\n const result = {}\r\n\r\n if (cloneProtoObject \u0026\u0026 Object.getPrototypeOf(target) !== JSON_PROTO) {\r\n return cloneProtoObject(target)\r\n }\r\n\r\n const targetKeys = getKeys(target)\r\n let i, il, key\r\n for (i = 0, il = targetKeys.length; i \u003C il; \u002B\u002Bi) {\r\n isNotPrototypeKey(key = targetKeys[i]) \u0026\u0026\r\n (result[key] = clone(target[key]))\r\n }\r\n return result\r\n }\r\n\r\n function concatArrays (target, source) {\r\n const tl = target.length\r\n const sl = source.length\r\n let i = 0\r\n const result = new Array(tl \u002B sl)\r\n for (i; i \u003C tl; \u002B\u002Bi) {\r\n result[i] = clone(target[i])\r\n }\r\n for (i = 0; i \u003C sl; \u002B\u002Bi) {\r\n result[i \u002B tl] = clone(source[i])\r\n }\r\n return result\r\n }\r\n\r\n const propertyIsEnumerable = Object.prototype.propertyIsEnumerable\r\n function getSymbolsAndKeys (value) {\r\n const result = Object.keys(value)\r\n const keys = Object.getOwnPropertySymbols(value)\r\n for (let i = 0, il = keys.length; i \u003C il; \u002B\u002Bi) {\r\n propertyIsEnumerable.call(value, keys[i]) \u0026\u0026 result.push(keys[i])\r\n }\r\n return result\r\n }\r\n\r\n const getKeys = options?.symbols\r\n ? getSymbolsAndKeys\r\n : Object.keys\r\n\r\n const cloneProtoObject = typeof options?.cloneProtoObject === \u0027function\u0027\r\n ? options.cloneProtoObject\r\n : undefined\r\n\r\n const isMergeableObject = typeof options?.isMergeableObject === \u0027function\u0027\r\n ? options.isMergeableObject\r\n : defaultIsMergeableObjectFactory()\r\n\r\n function isPrimitive (value) {\r\n return typeof value !== \u0027object\u0027 || value === null\r\n }\r\n\r\n const mergeArray = options \u0026\u0026 typeof options.mergeArray === \u0027function\u0027\r\n ? options.mergeArray({ clone, deepmerge: _deepmerge, getKeys, isMergeableObject })\r\n : concatArrays\r\n\r\n function clone (entry) {\r\n return isMergeableObject(entry)\r\n ? Array.isArray(entry)\r\n ? cloneArray(entry)\r\n : cloneObject(entry)\r\n : entry\r\n }\r\n\r\n function mergeObject (target, source) {\r\n const result = {}\r\n const targetKeys = getKeys(target)\r\n const sourceKeys = getKeys(source)\r\n let i, il, key\r\n for (i = 0, il = targetKeys.length; i \u003C il; \u002B\u002Bi) {\r\n isNotPrototypeKey(key = targetKeys[i]) \u0026\u0026\r\n (sourceKeys.indexOf(key) === -1) \u0026\u0026\r\n (result[key] = clone(target[key]))\r\n }\r\n\r\n for (i = 0, il = sourceKeys.length; i \u003C il; \u002B\u002Bi) {\r\n if (!isNotPrototypeKey(key = sourceKeys[i])) {\r\n continue\r\n }\r\n\r\n if (key in target) {\r\n if (targetKeys.indexOf(key) !== -1) {\r\n if (cloneProtoObject \u0026\u0026 isMergeableObject(source[key]) \u0026\u0026 Object.getPrototypeOf(source[key]) !== JSON_PROTO) {\r\n result[key] = cloneProtoObject(source[key])\r\n } else {\r\n result[key] = _deepmerge(target[key], source[key])\r\n }\r\n }\r\n } else {\r\n result[key] = clone(source[key])\r\n }\r\n }\r\n return result\r\n }\r\n\r\n function _deepmerge (target, source) {\r\n const sourceIsArray = Array.isArray(source)\r\n const targetIsArray = Array.isArray(target)\r\n\r\n if (isPrimitive(source)) {\r\n return source\r\n } else if (!isMergeableObject(target)) {\r\n return clone(source)\r\n } else if (sourceIsArray \u0026\u0026 targetIsArray) {\r\n return mergeArray(target, source)\r\n } else if (sourceIsArray !== targetIsArray) {\r\n return clone(source)\r\n } else {\r\n return mergeObject(target, source)\r\n }\r\n }\r\n\r\n function _deepmergeAll () {\r\n switch (arguments.length) {\r\n case 0:\r\n return {}\r\n case 1:\r\n return clone(arguments[0])\r\n case 2:\r\n return _deepmerge(arguments[0], arguments[1])\r\n }\r\n let result\r\n for (let i = 0, il = arguments.length; i \u003C il; \u002B\u002Bi) {\r\n result = _deepmerge(result, arguments[i])\r\n }\r\n return result\r\n }\r\n\r\n return options?.all\r\n ? _deepmergeAll\r\n : _deepmerge\r\n}\r\n\r\nwindow.d1 = deepmergeConstructor","TestCases":[{"Name":"lodash","Code":"var a = { a: \u0027oh\u0027, b: \u0027my\u0027, c: { a: \u0027a\u0027, b: { c: \u0027c\u0027 } } };\r\nvar b = { c: { b: { d: \u0027a\u0027 }, c: { d: \u0027d\u0027 } } };\r\nvar c = _.merge({}, a, b);\r\nconst x = {\r\n foo: { bar: 3 },\r\n array: [{\r\n does: \u0027work\u0027,\r\n too: [ 1, 2, 3 ]\r\n }]\r\n}\r\n \r\nconst y = {\r\n foo: { baz: 4 },\r\n quux: 5,\r\n array: [{\r\n does: \u0027work\u0027,\r\n too: [ 4, 5, 6 ]\r\n }, {\r\n really: \u0027yes\u0027\r\n }]\r\n}\r\nvar z = _.merge({}, x, y);","IsDeferred":false},{"Name":"deepmerge","Code":"var a = { a: \u0027oh\u0027, b: \u0027my\u0027, c: { a: \u0027a\u0027, b: { c: \u0027c\u0027 } } };\r\nvar b = { c: { b: { d: \u0027a\u0027 }, c: { d: \u0027d\u0027 } } };\r\nvar c = deepmerge({}, a, b);\r\nconst x = {\r\n foo: { bar: 3 },\r\n array: [{\r\n does: \u0027work\u0027,\r\n too: [ 1, 2, 3 ]\r\n }]\r\n}\r\n \r\nconst y = {\r\n foo: { baz: 4 },\r\n quux: 5,\r\n array: [{\r\n does: \u0027work\u0027,\r\n too: [ 4, 5, 6 ]\r\n }, {\r\n really: \u0027yes\u0027\r\n }]\r\n}\r\nvar z = deepmerge({}, x, y);","IsDeferred":false},{"Name":"deepmerge-ts","Code":"var a = { a: \u0027oh\u0027, b: \u0027my\u0027, c: { a: \u0027a\u0027, b: { c: \u0027c\u0027 } } };\r\nvar b = { c: { b: { d: \u0027a\u0027 }, c: { d: \u0027d\u0027 } } };\r\nvar c = deepmerge({}, a, b);\r\nconst x = {\r\n foo: { bar: 3 },\r\n array: [{\r\n does: \u0027work\u0027,\r\n too: [ 1, 2, 3 ]\r\n }]\r\n}\r\n \r\nconst y = {\r\n foo: { baz: 4 },\r\n quux: 5,\r\n array: [{\r\n does: \u0027work\u0027,\r\n too: [ 4, 5, 6 ]\r\n }, {\r\n really: \u0027yes\u0027\r\n }]\r\n}\r\nvar z = deepmergeTs({}, x, y);","IsDeferred":false},{"Name":"@fasify/deepmerge","Code":"var a = { a: \u0027oh\u0027, b: \u0027my\u0027, c: { a: \u0027a\u0027, b: { c: \u0027c\u0027 } } };\r\nvar b = { c: { b: { d: \u0027a\u0027 }, c: { d: \u0027d\u0027 } } };\r\nvar c = deepmerge({}, a, b);\r\nconst x = {\r\n foo: { bar: 3 },\r\n array: [{\r\n does: \u0027work\u0027,\r\n too: [ 1, 2, 3 ]\r\n }]\r\n}\r\n \r\nconst y = {\r\n foo: { baz: 4 },\r\n quux: 5,\r\n array: [{\r\n does: \u0027work\u0027,\r\n too: [ 4, 5, 6 ]\r\n }, {\r\n really: \u0027yes\u0027\r\n }]\r\n}\r\nvar z = d1({}, x, y);","IsDeferred":false}]}