UNPKG

@storm-stack/utilities

Version:

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

17 lines (16 loc) 399 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.throttle = throttle; 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; }