UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

23 lines (19 loc) 406 B
/*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ // src/throttle/index.ts function throttle(func, limit) { let inThrottle = false; return function(...args) { if (!inThrottle) { func.apply(this, args); inThrottle = true; setTimeout(() => { inThrottle = false; }, limit); } }; } export { throttle };