{"ScriptPreparationCode":null,"TestCases":[{"Name":"retry1","Code":"function callMe(success, failure) {\r\n const chance = 0;\r\n\r\n setTimeout(() =\u003E {\r\n if (chance \u003E= Math.random()) {\r\n success(\u0022Succeeded\u0022);\r\n } else {\r\n failure(new Error(\u0022Failure\u0022));\r\n }\r\n }, 0);\r\n}\r\n\r\nconst retry1 = async (func, attempts) =\u003E {\r\n while (true) {\r\n try {\r\n return await new Promise(func);\r\n } catch (err) {\r\n attempts--;\r\n\r\n if (attempts === 0)\r\n throw err;\r\n }\r\n }\r\n};\r\n\r\nconst t0 = performance.now();\r\nretry1(callMe, 50).then(res =\u003E console.log(\u0022success: \u0022 \u002B res)).catch(res =\u003E console.log(\u0022failure: \u0022 \u002B res));\r\nconst t1 = performance.now();\r\nconsole.log(\u0060Call to retry1 took ${t1 - t0} milliseconds.\u0060);\r\n","IsDeferred":false},{"Name":"retry2","Code":"function callMe(success, failure) {\r\n const chance = 0;\r\n\r\n setTimeout(() =\u003E {\r\n if (chance \u003E= Math.random()) {\r\n success(\u0022Succeeded\u0022);\r\n } else {\r\n failure(new Error(\u0022Failure\u0022));\r\n }\r\n }, 0);\r\n}\r\n\r\nconst retry2 = (func, attempts) =\u003E\r\n new Promise(func).catch((err) =\u003E {\r\n if (attempts \u003E 0) {\r\n return retry2(func, attempts - 1);\r\n }\r\n throw err;\r\n });\r\n\r\nconst t0 = performance.now();\r\nretry2(callMe, 50).then(res =\u003E console.log(\u0022success: \u0022 \u002B res)).catch(res =\u003E console.log(\u0022failure: \u0022 \u002B res));\r\nconst t1 = performance.now();\r\nconsole.log(\u0060Call to retry2 took ${t1 - t0} milliseconds.\u0060);\r\n","IsDeferred":false}]}