{"ScriptPreparationCode":null,"TestCases":[{"Name":"object spread","Code":"const obj = {};\r\nfor(i=0;i\u003C100000;i\u002B\u002B){\r\n obj[i] = \u0027some long string which will need to be copied\u0027;\r\n}\r\n\r\nconst obj2 = {key: \u0027This is final object\u0027}\r\n\r\nconst final = {obj2, ...obj};","IsDeferred":false},{"Name":"object assign","Code":"const obj = {};\r\nfor(i=0;i\u003C100000;i\u002B\u002B){\r\n obj[i] = \u0027some long string which will need to be copied\u0027;\r\n}\r\n\r\nconst obj2 = {key: \u0027This is final object\u0027}\r\n\r\nconst final = Object.assign({}, obj2, obj)","IsDeferred":false},{"Name":"immutable-js","Code":"const obj = {};\r\nfor(i=0;i\u003C100000;i\u002B\u002B){\r\n obj[i] = \u0027some long string which will need to be copied\u0027;\r\n}\r\nconst immObj = Immutable.Map();\r\n\r\nconst obj2 = {key: \u0027This is final object\u0027}\r\n\r\nconst final = immObj.set(obj2);","IsDeferred":false},{"Name":"immutability-helper","Code":"\r\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\r\nvar splice = Array.prototype.splice;\r\n\r\nvar toString = Object.prototype.toString\r\nvar type = function(obj) {\r\n return toString.call(obj).slice(8, -1);\r\n}\r\n\r\nvar assign = Object.assign || /* istanbul ignore next */ function assign(target, source) {\r\n getAllKeys(source).forEach(function(key) {\r\n if (hasOwnProperty.call(source, key)) {\r\n target[key] = source[key];\r\n }\r\n });\r\n return target;\r\n};\r\n\r\nvar getAllKeys = typeof Object.getOwnPropertySymbols === \u0027function\u0027 ?\r\n function(obj) { return Object.keys(obj).concat(Object.getOwnPropertySymbols(obj)) } :\r\n /* istanbul ignore next */ function(obj) { return Object.keys(obj) };\r\n\r\n/* istanbul ignore next */\r\nfunction copy(object) {\r\n if (Array.isArray(object)) {\r\n return assign(object.constructor(object.length), object)\r\n } else if (type(object) === \u0027Map\u0027) {\r\n return new Map(object)\r\n } else if (type(object) === \u0027Set\u0027) {\r\n return new Set(object)\r\n } else if (object \u0026\u0026 typeof object === \u0027object\u0027) {\r\n var prototype = object.constructor \u0026\u0026 object.constructor.prototype\r\n return assign(Object.create(prototype || null), object);\r\n } else {\r\n return object;\r\n }\r\n}\r\n\r\nfunction newContext() {\r\n var commands = assign({}, defaultCommands);\r\n update.extend = function(directive, fn) {\r\n commands[directive] = fn;\r\n };\r\n update.isEquals = function(a, b) { return a === b; };\r\n\r\n return update;\r\n\r\n function update(object, spec) {\r\n if (typeof spec === \u0027function\u0027) {\r\n return spec(object);\r\n }\r\n\r\n if (!(Array.isArray(object) \u0026\u0026 Array.isArray(spec))) {\r\n \r\n }\r\n\r\n \r\n var nextObject = object;\r\n var index, key;\r\n getAllKeys(spec).forEach(function(key) {\r\n if (hasOwnProperty.call(commands, key)) {\r\n var objectWasNextObject = object === nextObject;\r\n nextObject = commands[key](spec[key], nextObject, spec, object);\r\n if (objectWasNextObject \u0026\u0026 update.isEquals(nextObject, object)) {\r\n nextObject = object;\r\n }\r\n } else {\r\n var nextValueForKey =\r\n type(object) === \u0027Map\u0027\r\n ? update(object.get(key), spec[key])\r\n : update(object[key], spec[key]);\r\n if (!update.isEquals(nextValueForKey, nextObject[key]) || typeof nextValueForKey === \u0027undefined\u0027 \u0026\u0026 !hasOwnProperty.call(object, key)) {\r\n if (nextObject === object) {\r\n nextObject = copy(object);\r\n }\r\n if (type(nextObject) === \u0027Map\u0027) {\r\n nextObject.set(key, nextValueForKey);\r\n } else {\r\n nextObject[key] = nextValueForKey;\r\n }\r\n }\r\n }\r\n })\r\n return nextObject;\r\n }\r\n\r\n}\r\n\r\nvar defaultCommands = {\r\n $push: function(value, nextObject, spec) {\r\n \r\n return value.length ? nextObject.concat(value) : nextObject;\r\n },\r\n $unshift: function(value, nextObject, spec) {\r\n // invariantPushAndUnshift(nextObject, spec, \u0027$unshift\u0027);\r\n return value.length ? value.concat(nextObject) : nextObject;\r\n },\r\n $splice: function(value, nextObject, spec, originalObject) {\r\n // invariantSplices(nextObject, spec);\r\n value.forEach(function(args) {\r\n // invariantSplice(args);\r\n if (nextObject === originalObject \u0026\u0026 args.length) nextObject = copy(originalObject);\r\n splice.apply(nextObject, args);\r\n });\r\n return nextObject;\r\n },\r\n $set: function(value, nextObject, spec) {\r\n // invariantSet(spec);\r\n return value;\r\n },\r\n $toggle: function(targets, nextObject) {\r\n // invariantSpecArray(targets, \u0027$toggle\u0027);\r\n var nextObjectCopy = targets.length ? copy(nextObject) : nextObject;\r\n\r\n targets.forEach(function(target) {\r\n nextObjectCopy[target] = !nextObject[target];\r\n });\r\n\r\n return nextObjectCopy;\r\n },\r\n $unset: function(value, nextObject, spec, originalObject) {\r\n // invariantSpecArray(value, \u0027$unset\u0027);\r\n value.forEach(function(key) {\r\n if (Object.hasOwnProperty.call(nextObject, key)) {\r\n if (nextObject === originalObject) nextObject = copy(originalObject);\r\n delete nextObject[key];\r\n }\r\n });\r\n return nextObject;\r\n },\r\n $add: function(value, nextObject, spec, originalObject) {\r\n // invariantMapOrSet(nextObject, \u0027$add\u0027);\r\n // invariantSpecArray(value, \u0027$add\u0027);\r\n if (type(nextObject) === \u0027Map\u0027) {\r\n value.forEach(function(pair) {\r\n var key = pair[0];\r\n var value = pair[1];\r\n if (nextObject === originalObject \u0026\u0026 nextObject.get(key) !== value) nextObject = copy(originalObject);\r\n nextObject.set(key, value);\r\n });\r\n } else {\r\n value.forEach(function(value) {\r\n if (nextObject === originalObject \u0026\u0026 !nextObject.has(value)) nextObject = copy(originalObject);\r\n nextObject.add(value);\r\n });\r\n }\r\n return nextObject;\r\n },\r\n $remove: function(value, nextObject, spec, originalObject) {\r\n // invariantMapOrSet(nextObject, \u0027$remove\u0027);\r\n // invariantSpecArray(value, \u0027$remove\u0027);\r\n value.forEach(function(key) {\r\n if (nextObject === originalObject \u0026\u0026 nextObject.has(key)) nextObject = copy(originalObject);\r\n nextObject.delete(key);\r\n });\r\n return nextObject;\r\n },\r\n $merge: function(value, nextObject, spec, originalObject) {\r\n // invariantMerge(nextObject, value);\r\n getAllKeys(value).forEach(function(key) {\r\n if (value[key] !== nextObject[key]) {\r\n if (nextObject === originalObject) nextObject = copy(originalObject);\r\n nextObject[key] = value[key];\r\n }\r\n });\r\n return nextObject;\r\n },\r\n $apply: function(value, original) {\r\n // invariantApply(value);\r\n return value(original);\r\n }\r\n};\r\n\r\nvar contextForExport = newContext();\r\n\r\n\r\nconst obj = {};\r\nfor(i=0;i\u003C100000;i\u002B\u002B){\r\n obj[i] = \u0027some long string which will need to be copied\u0027;\r\n}\r\n\r\nconst obj2 = {key: \u0027This is final object\u0027}\r\n\r\nconst final = contextForExport(obj2, {$merge: obj});\r\n","IsDeferred":false}]}