{"ScriptPreparationCode":"var sameObjRef = { id: 1, name: \u0022test\u0022 };\r\nvar sameArrRef = [1, 2, 3];\r\n\r\nvar testCases = {\r\n // Case 1: Primitive values (should hit fast path)\r\n sameNumber: { previous: 42, current: 42 },\r\n differentNumbers: { previous: 42, current: 43 },\r\n sameString: { previous: \u0022hello\u0022, current: \u0022hello\u0022 },\r\n differentStrings: { previous: \u0022hello\u0022, current: \u0022world\u0022 },\r\n \r\n // Case 2: null/undefined values\r\n bothNull: { previous: null, current: null },\r\n bothUndefined: { previous: undefined, current: undefined },\r\n nullVsUndefined: { previous: null, current: undefined },\r\n nullVsObject: { previous: null, current: { a: 1 } },\r\n undefinedVsObject: { previous: undefined, current: { a: 1 } },\r\n \r\n // Case 3: Same object references (should hit fast path)\r\n sameObjectRef: { \r\n previous: sameObjRef, \r\n current: sameObjRef \r\n },\r\n sameArrayRef: {\r\n previous: sameArrRef,\r\n current: sameArrRef\r\n },\r\n \r\n // Case 4: Different objects with same content (requires shallowEqual)\r\n differentObjectsSameContent: {\r\n previous: { id: 1, name: \u0022test\u0022 },\r\n current: { id: 1, name: \u0022test\u0022 }\r\n },\r\n differentArraysSameContent: {\r\n previous: [1, 2, 3],\r\n current: [1, 2, 3]\r\n },\r\n \r\n // Case 5: Different objects with different content\r\n differentObjects: {\r\n previous: { id: 1, name: \u0022test\u0022 },\r\n current: { id: 2, name: \u0022different\u0022 }\r\n },\r\n differentArrays: {\r\n previous: [1, 2, 3],\r\n current: [4, 5, 6]\r\n },\r\n \r\n // Case 6: Nested objects (shallowEqual won\u0027t catch deep differences)\r\n nestedObjectsSame: {\r\n previous: { a: 1, b: sameObjRef },\r\n current: { a: 1, b: sameObjRef }\r\n },\r\n nestedObjectsDifferent: {\r\n previous: { a: 1, b: { nested: true } },\r\n current: { a: 1, b: { nested: false } }\r\n },\r\n \r\n // Case 7: Mixed types\r\n objectVsArray: {\r\n previous: { 0: 1, 1: 2 },\r\n current: [1, 2]\r\n },\r\n numberVsStringNumber: {\r\n previous: 42,\r\n current: \u002242\u0022\r\n }\r\n};","TestCases":[{"Name":"Checks before shallow","Code":"const {shallowEqual} = window[\u0027fast-equals\u0027];\r\n\r\nfunction optimizedComparison(prevVal, newVal) {\r\n let normalizedPrevious = prevVal.current ?? undefined;\r\n let normalizedNew = newVal.current ?? undefined;\r\n let areValuesEqual;\r\n \r\n if (normalizedPrevious === normalizedNew) {\r\n areValuesEqual = true;\r\n } else if (normalizedPrevious == null || normalizedNew == null) {\r\n areValuesEqual = false;\r\n } else {\r\n areValuesEqual = shallowEqual(normalizedPrevious, normalizedNew);\r\n }\r\n \r\n return areValuesEqual;\r\n}\r\n\r\nObject.entries(testCases).forEach(([testName, testCase]) =\u003E {\r\n // Set up the refs for this test case\r\n let previousValueRef = {current: testCase.previous};\r\n let newValueRef = {current: testCase.current};\r\n \r\n optimizedComparison(previousValueRef, newValueRef)\r\n});","IsDeferred":false},{"Name":"Just Shallow","Code":"const {shallowEqual} = window[\u0027fast-equals\u0027];\r\n\r\nfunction originalComparison(prevVal, newVal) {\r\n return shallowEqual(prevVal.current ?? undefined, newVal.current ?? undefined);\r\n}\r\n\r\nObject.entries(testCases).forEach(([testName, testCase]) =\u003E {\r\n // Set up the refs for this test case\r\n let previousValueRef = {current: testCase.previous};\r\n let newValueRef = {current: testCase.current};\r\n \r\n originalComparison(previousValueRef, newValueRef)\r\n});","IsDeferred":false}]}