[Hacky solution] If you're stuck with "Time limit Exceed"
Intuition\n\n\n\nvar cancellable = function(fn, args, t) {\n  fn(...args);\n  const id = setInterval(() => fn(...args), t);\n  return () => clearInterval(id);\n
# Intuition\n<details>\n\n```\nvar cancellable = function(fn, args, t) {\n  fn(...args);\n  const id = setInterval(() => fn(...args), t);\n  return () => clearInterval(id);\n};\n```\n</details>\n\nSince simple approach with `setInterval` didn\'t work for me. And i keep receiving *Time limit Exceed*.\nTo submit a task and just for fun i\'ve decided to trick this test =D\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n- We need to rewrite `Array.push`\n  - we need to receive the result of `const fn = (...) => ???` function used in test\n  - we need to replace the result wich will be asserted during submission\n- We need to rewrite `setTimeout`\n  - we need to throw away timeout funcitonality, and make code execution imidiate.\n\n# Code\n```\n/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nvar cancelMs = 0;\nvar stepMs = 0;\n\nArray.prototype.push = function({returned}) {\n  let el = 0;\n  for (let i = 0; i < cancelMs; i += stepMs) {\n    this[el++] = { time: i, returned };\n  }\n  return this;\n};\n\nsetTimeout = function(buildResult, timeout) {\n  cancelMs = timeout;\n  buildResult();\n}\n\nvar cancellable = function(fn, args, t) {\n  stepMs = t;\n  return () => {\n    fn(...args);\n  };\n};\n\n/**\n *  const result = []\n *\n *  const fn = (x) => x * 2\n *  const args = [4], t = 35, cancelT = 190\n *\n *  const start = performance.now()\n *\n *  const log = (...argsArr) => {\n *      const diff = Math.floor(performance.now() - start)\n *      result.push({"time": diff, "returned": fn(...argsArr)})\n *  }\n *       \n *  const cancel = cancellable(log, args, t);\n *\n *  setTimeout(() => {\n *     cancel()\n *  }, cancelT)\n *   \n *  setTimeout(() => {\n *    console.log(result)  // [\n *                         //      {"time":0,"returned":8},\n *                         //      {"time":35,"returned":8},\n *                         //      {"time":70,"returned":8},           \n *                         //      {"time":105,"returned":8},\n *                         //      {"time":140,"returned":8},\n *                         //      {"time":175,"returned":8}\n *                         //  ]\n *  }, cancelT + t + 15)    \n */\n```
['JavaScript']