MCPcopy Create free account
hub / github.com/TanStack/virtual / debounce

Function debounce

packages/virtual-core/src/utils.ts:81–91  ·  view source on GitHub ↗
(
  targetWindow: Window & typeof globalThis,
  fn: Function,
  ms: number,
)

Source from the content-addressed store, hash-verified

79export const approxEqual = (a: number, b: number) => Math.abs(a - b) < 1
80
81export const debounce = (
82 targetWindow: Window & typeof globalThis,
83 fn: Function,
84 ms: number,
85) => {
86 let timeoutId: number
87 return function (this: any, ...args: Array<any>) {
88 targetWindow.clearTimeout(timeoutId)
89 timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms)
90 }
91}

Callers 2

observeElementOffsetFunction · 0.90
observeWindowOffsetFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected