{"ScriptPreparationCode":"var source = {a:1,b:1,c:1,d:1,e:1,f:1,g:1,h:{a:-1,b:1,c:1,d:1,e:1,f:1,g:1}};\r\n//var source = {a:1};\r\n//var CloneFactory = FastClone.factory(source);\r\n\r\nfunction clone(value) {\r\n var type = typeof value;\r\n switch (type) {\r\n case \u0027object\u0027:\r\n // null and undefined\r\n if (value == null) {\r\n return value;\r\n }\r\n var result = void 0;\r\n if (value instanceof Date) {\r\n result = new Date();\r\n result.setTime(value.getTime());\r\n return result;\r\n }\r\n else if (value instanceof RegExp) {\r\n result = newRegExp(value);\r\n return result;\r\n }\r\n result = JSON.parse(JSON.stringify(value));\r\n fixTypes(value, result);\r\n return result;\r\n default:\r\n return value;\r\n }\r\n }\r\n function fixPropertyValue(original, copy, key) {\r\n var originalValue = original[key];\r\n var originalType = typeof originalValue;\r\n switch (originalType) {\r\n case \u0027object\u0027:\r\n if (originalValue instanceof Date) {\r\n var newValue = new Date();\r\n newValue.setTime(originalValue.getTime());\r\n copy[key] = newValue;\r\n }\r\n else if (originalValue instanceof RegExp) {\r\n copy[key] = newRegExp(originalValue);\r\n }\r\n else if (originalValue == null) {\r\n copy[key] = originalValue;\r\n }\r\n else {\r\n fixTypes(originalValue, copy[key]);\r\n }\r\n break;\r\n case \u0027number\u0027:\r\n if (isNaN(originalValue)) {\r\n copy[key] = NaN;\r\n }\r\n else if (originalValue == Infinity) {\r\n copy[key] = Infinity;\r\n }\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n function fixTypes(original, copy) {\r\n if (original instanceof Array) {\r\n for (var index = 0; index \u003C original.length; index\u002B\u002B) {\r\n fixPropertyValue(original, copy, index);\r\n }\r\n }\r\n else {\r\n var keys = Object.getOwnPropertyNames(original);\r\n keys.forEach(function (key) {\r\n fixPropertyValue(original, copy, key);\r\n });\r\n }\r\n }\r\n function newRegExp(value) {\r\n var regexpText = String(value);\r\n var slashIndex = regexpText.lastIndexOf(\u0027/\u0027);\r\n return new RegExp(regexpText.slice(1, slashIndex), regexpText.slice(slashIndex \u002B 1));\r\n }","TestCases":[{"Name":"JSON parse","Code":"var objects = [{ \u0027a\u0027: 1 }, { \u0027b\u0027: 2, c: 3, d: 4 }, {c:3}, 4, 5, 6 ,\u0027hello\u0027];\r\n //var objects = {a:1,b:1,c:1,d:1,e:1,f:1,g:1,h:{a:-1,b:1,c:1,d:1,e:1,f:1,g:1}};\r\nvar deep = JSON.parse(JSON.stringify(objects));","IsDeferred":false},{"Name":"_.deepClone","Code":"var objects = [{ \u0027a\u0027: 1 }, { \u0027b\u0027: 2, c: 3, d: 4 }, {c:3}, 4, 5, 6 ,\u0027hello\u0027];\r\n //var objects = {a:1,b:1,c:1,d:1,e:1,f:1,g:1,h:{a:-1,b:1,c:1,d:1,e:1,f:1,g:1}};\r\nvar deep = _.cloneDeep(objects);","IsDeferred":false},{"Name":"fast-clone","Code":" //var objects = {a:1,b:1,c:1,d:1,e:1,f:1,g:1,h:{a:-1,b:1,c:1,d:1,e:1,f:1,g:1}};\r\nvar objects = [{ \u0027a\u0027: 1 }, { \u0027b\u0027: 2, c: 3, d: 4 }, {c:3}, 4, 5, 6 ,\u0027hello\u0027];\r\nvar deep = clone(objects);","IsDeferred":false}]}