• Creates a throttled function that limits the rate at which the provided function can be called. The function will be called at most once per specified delay period.

    Type Parameters

    • T extends ((...args) => unknown)

    Parameters

    • fn: T

      The function to throttle.

    • delay: number

      The number of milliseconds to throttle by.

    Returns ((...args) => void)

    A throttled version of the function.

      • (...args): void
      • Parameters

        • Rest ...args: Parameters<T>

        Returns void

    Example

    const throttledScroll = throttle(handleScroll, 100);
    window.addEventListener('scroll', throttledScroll);

    // In React/React Native:
    const handleResize = throttle(() => {
    // Update layout
    }, 250);

Generated using TypeDoc