{"ScriptPreparationCode":"window.obj = {};\r\n\r\nfor (let i = 0; i \u003C 10000; i\u002B\u002B) {\r\n obj[\u0027key\u0027 \u002B i] = \u0027value\u0027 \u002B i;\r\n}","TestCases":[{"Name":"Default Factory","Code":"const TimeFactory = time =\u003E {\r\n const state = setFactoryState(time)\r\n\r\n function setFactoryState(time) {\r\n if (!time || typeof time !== \u0027string\u0027 || !time.includes(\u0027.\u0027)) {\r\n return {\r\n hours: 0,\r\n minutes: 0,\r\n seconds: 0\r\n }\r\n }\r\n\r\n const [h, m, s] = decimalHoursToTime(time).split(\u0027:\u0027)\r\n const nextState = {\r\n hours: \u002Bh,\r\n minutes: \u002Bm,\r\n seconds: \u002Bs\r\n }\r\n // const { hours, minutes, seconds } = processTime(nextState)\r\n\r\n return {\r\n // hours,\r\n // minutes,\r\n // seconds\r\n ...processTime(nextState)\r\n }\r\n };\r\n\r\n return {\r\n ...formatTime(state),\r\n }\r\n};\r\n\r\nconst decimalHoursToTime = decimalHours =\u003E {\r\n const isWholeHour = decimalHours =\u003E {\r\n // We have an integer\r\n const isInteger = decimalHours \u0026\u0026 Number.isInteger(\u002BdecimalHours);\r\n const [, decimals] = decimalHours \u0026\u0026 decimalHours.includes(\u0027.\u0027) ? decimalHours.split(\u0027.\u0027) : \u00270.0\u0027;\r\n const isDecimalZero = \u002Bdecimals === 0;\r\n\r\n return isInteger || isDecimalZero;\r\n }\r\n\r\n if (isWholeHour(decimalHours)) {\r\n const hoursRounded = (\u002BdecimalHours).toFixed();\r\n\r\n return \u0060${_.padStart(hoursRounded, 2, 0)}:00:00\u0060;\r\n }\r\n\r\n const [hours, decimals] = decimalHours.split(\u0027.\u0027)\r\n const [minutes, remainder] = (\u002B\u00600.${decimals}\u0060 * 60).toString().split(\u0027.\u0027)\r\n const seconds = !remainder ? \u002700\u0027 : (\u002B\u00600.${remainder}\u0060 * 60).toFixed()\r\n\r\n return \u0060${_.padStart(hours, 2, 0)}:${_.padStart(minutes, 2, 0)}:${_.padStart(seconds, 2, 0)}\u0060\r\n};\r\n\r\nconst processTime = ({ hours, minutes, seconds }) =\u003E {\r\n if (seconds \u003C= 59) {\r\n return {\r\n seconds,\r\n minutes,\r\n hours\r\n }\r\n }\r\n\r\n if (seconds \u003E 59) {\r\n const nextSeconds = seconds - 60\r\n const nextMinutes = minutes \u002B 1 === 60 ? 0 : minutes \u002B 1\r\n const nextHours = minutes \u002B 1 === 60 ? hours \u002B 1 : hours\r\n\r\n return {\r\n seconds: nextSeconds,\r\n minutes: nextMinutes,\r\n hours: nextHours\r\n }\r\n }\r\n};\r\n\r\nconst formatTime = ({ hours, minutes, seconds }) =\u003E ({\r\n defaultFormat() {\r\n const strHours = hours.toString()\r\n const strMinutes = minutes.toString()\r\n const strSeconds = seconds.toString()\r\n\r\n return \u0060${_.padStart(strHours, 2, 0)}:${_.padStart(strMinutes, 2, 0)}:${_.padStart(strSeconds, 2, 0)}\u0060\r\n }\r\n});","IsDeferred":false},{"Name":"Ice Factory","Code":"const TimeFactory = time =\u003E {\r\n const state = setFactoryState(time)\r\n\r\n function setFactoryState(time) {\r\n if (!time || typeof time !== \u0027string\u0027 || !time.includes(\u0027.\u0027)) {\r\n return {\r\n hours: 0,\r\n minutes: 0,\r\n seconds: 0\r\n }\r\n }\r\n\r\n const [h, m, s] = decimalHoursToTime(time).split(\u0027:\u0027)\r\n const nextState = {\r\n hours: \u002Bh,\r\n minutes: \u002Bm,\r\n seconds: \u002Bs\r\n }\r\n\r\n return Object.freeze({\r\n ...processTime(nextState)\r\n })\r\n };\r\n\r\n return Object.freeze({\r\n ...processTime(nextState)\r\n })\r\n};\r\n\r\nconst decimalHoursToTime = decimalHours =\u003E {\r\n const isWholeHour = decimalHours =\u003E {\r\n // We have an integer\r\n const isInteger = decimalHours \u0026\u0026 Number.isInteger(\u002BdecimalHours);\r\n const [, decimals] = decimalHours \u0026\u0026 decimalHours.includes(\u0027.\u0027) ? decimalHours.split(\u0027.\u0027) : \u00270.0\u0027;\r\n const isDecimalZero = \u002Bdecimals === 0;\r\n\r\n return isInteger || isDecimalZero;\r\n }\r\n\r\n if (isWholeHour(decimalHours)) {\r\n const hoursRounded = (\u002BdecimalHours).toFixed();\r\n\r\n return \u0060${padStart(hoursRounded, 2, 0)}:00:00\u0060;\r\n }\r\n\r\n const [hours, decimals] = decimalHours.split(\u0027.\u0027)\r\n const [minutes, remainder] = (\u002B\u00600.${decimals}\u0060 * 60).toString().split(\u0027.\u0027)\r\n const seconds = !remainder ? \u002700\u0027 : (\u002B\u00600.${remainder}\u0060 * 60).toFixed()\r\n\r\n return \u0060${_.padStart(hours, 2, 0)}:${_.padStart(minutes, 2, 0)}:${_.padStart(seconds, 2, 0)}\u0060\r\n};\r\n\r\nconst processTime = ({ hours, minutes, seconds }) =\u003E {\r\n if (seconds \u003C= 59) {\r\n return {\r\n seconds,\r\n minutes,\r\n hours\r\n }\r\n }\r\n\r\n if (seconds \u003E 59) {\r\n const nextSeconds = seconds - 60\r\n const nextMinutes = minutes \u002B 1 === 60 ? 0 : minutes \u002B 1\r\n const nextHours = minutes \u002B 1 === 60 ? hours \u002B 1 : hours\r\n\r\n return {\r\n seconds: nextSeconds,\r\n minutes: nextMinutes,\r\n hours: nextHours\r\n }\r\n }\r\n};\r\n\r\nconst formatTime = ({ hours, minutes, seconds }) =\u003E {\r\n function defaultFormat() {\r\n const strHours = hours.toString()\r\n const strMinutes = minutes.toString()\r\n const strSeconds = seconds.toString()\r\n\r\n return \u0060${_.padStart(strHours, 2, 0)}:${_.padStart(strMinutes, 2, 0)}:${_.padStart(strSeconds, 2, 0)}\u0060\r\n }\r\n\r\n return Object.freeze({\r\n defaultFormat\r\n })\r\n};","IsDeferred":false}]}