let c=e=>setTimeout(e,16),f=e=>clearTimeout(e);typeof window<"u"&&"requestAnimationFrame"in window&&(c=e=>window.requestAnimationFrame(e),f=e=>window.cancelAnimationFrame(e));let r=0;const a=new Map;function l(e){a.delete(e)}function u(e,n=1){r+=1;const t=r;function i(o){if(o===0)l(t),e();else{const d=c(()=>{i(o-1)});a.set(t,d)}}return i(n),t}u.cancel=e=>{const n=a.get(e);return l(n),f(n)};export{u as default};
