UNPKG

@amxdev/throttle

Version:

Throttle a function to limit calls within a time frame.

14 lines (13 loc) 348 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.throttle = throttle; function throttle(func, limit) { let inThrottle; return (...args) => { if (!inThrottle) { func(...args); inThrottle = true; setTimeout(() => (inThrottle = false), limit); } }; }