// refer: https://github.com/antfu/plum-demo/blob/main/src/App.vue function frame() { const tasks: Function[] = [] pendingTasks = pendingTasks.filter((i) => { if (Math.random() > 0.4) { tasks.push(i) return false } return true }) tasks.forEach(fn => fn()) } let framesCount = 0 function startFrame() { requestAnimationFrame(() => { framesCount += 1 if (framesCount % 3 === 0) frame() startFrame() }) } startFrame()