UNPKG

locadot

Version:

Secure your local development environment with HTTPS and custom domains like dev.localhost.

15 lines (14 loc) 418 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDebounce = useDebounce; const debounceStore = new WeakMap(); function useDebounce(timeout, fn) { if (debounceStore.has(fn)) { clearTimeout(debounceStore.get(fn)); } const timer = setTimeout(() => { fn(); debounceStore.delete(fn); // cleanup }, timeout); debounceStore.set(fn, timer); }