import wrapperRaf from './raf.mjs';

function throttleByAnimationFrame(fn) {
  let requestId;
  const later = (args) => () => {
    requestId = null;
    fn(...args);
  };
  const throttled = (...args) => {
    if (requestId == null)
      requestId = wrapperRaf(later(args));
  };
  throttled.cancel = () => {
    wrapperRaf.cancel(requestId);
    requestId = null;
  };
  return throttled;
}

export { throttleByAnimationFrame as default };
//# sourceMappingURL=throttleByAnimationFrame.mjs.map
