UNPKG

@ledgerhq/live-common

Version:
24 lines 718 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.debounce = void 0; function debounce(func, waitMilliseconds, immediate = false) { let timeoutId; return (...args) => { const doLater = () => { timeoutId = undefined; if (!immediate) { func(...args); } }; const shouldCallNow = immediate && timeoutId === undefined; if (timeoutId !== undefined) { clearTimeout(timeoutId); } timeoutId = setTimeout(doLater, waitMilliseconds); if (shouldCallNow) { func(...args); } }; } exports.debounce = debounce; //# sourceMappingURL=debounce.js.map