MCPcopy Index your code
hub / github.com/epicweb-dev/epic-stack / debounce

Function debounce

app/utils/misc.tsx:243–254  ·  view source on GitHub ↗

* Simple debounce implementation

(
	fn: Callback,
	delay: number,
)

Source from the content-addressed store, hash-verified

241 * Simple debounce implementation
242 */
243function debounce<Callback extends (...args: Parameters<Callback>) => void>(
244 fn: Callback,
245 delay: number,
246) {
247 let timer: ReturnType<typeof setTimeout> | null = null
248 return (...args: Parameters<Callback>) => {
249 if (timer) clearTimeout(timer)
250 timer = setTimeout(() => {
251 fn(...args)
252 }, delay)
253 }
254}
255
256/**
257 * Debounce a callback function

Callers 1

useDebounceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected