34bdb7619aec468777c38b4a2062e59be029bd876b3a09582093e2c7dd7887308b91d3254f6705155a1714e4536bcb98fda033073da6e22102831894a3a779 388 B

12345678910111213141516171819202122
  1. import { cAF, rAF } from './raf.mjs';
  2. function throttleByRaf(cb) {
  3. let timer = 0;
  4. const throttle = (...args) => {
  5. if (timer) {
  6. cAF(timer);
  7. }
  8. timer = rAF(() => {
  9. cb(...args);
  10. timer = 0;
  11. });
  12. };
  13. throttle.cancel = () => {
  14. cAF(timer);
  15. timer = 0;
  16. };
  17. return throttle;
  18. }
  19. export { throttleByRaf };
  20. //# sourceMappingURL=throttleByRaf.mjs.map