UNPKG

@storm-stack/utilities

Version:

This package includes various base utility class and various functions to assist in the development process.

12 lines (11 loc) 297 B
export function throttle(func, throttleMs) { let lastCallTime; const throttledFunction = function(...args) { const now = Date.now(); if (lastCallTime == null || now - lastCallTime >= throttleMs) { lastCallTime = now; func(...args); } }; return throttledFunction; }