GeoLeaf Core API - v3.0.0
    Preparing search index...
    • Delays a function until it has stopped being called for wait milliseconds.

      With immediate, it fires on the leading edge instead — the first call runs at once and subsequent ones are swallowed until the window closes. Use it for search inputs and resize handlers; use throttle when you want a guaranteed cadence rather than a quiet period.

      ⚠️ The constraint is (...args: never[]) => unknown, NOT (...args: unknown[]) => unknown. The latter looks equivalent and is not: parameters are contravariant, so unknown[] demands a callback accepting unknown in every position, which rejects every concretely-typed callback(query: string) => void included. That was the real signature until 31/07/2026, and it made the documented example of this very function fail to compile (TS2345, frozen three days in the typecheck-docs-examples baseline). never[] is the idiom for "any function": it accepts them all, and Parameters<T> still recovers the true argument types.

      Type Parameters

      • T extends (...args: never[]) => unknown

      Parameters

      • func: T

        Function to debounce. this and arguments are forwarded.

      • wait: number = 250

        Quiet period in milliseconds. Defaults to 250.

      • immediate: boolean = false

        Fire on the leading edge instead of the trailing one. Defaults to false.

      Returns (...args: Parameters<T>) => void

      The debounced wrapper. ⚠️ It returns void — the wrapped return value is lost.