UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

25 lines (20 loc) 429 B
'use strict'; /*! * @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); } }; } exports.throttle = throttle;