Function delay

  • Invokes func after wait milliseconds. Any additional arguments are provided to func when it's invoked.

    Type Parameters

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

    Parameters

    • func: T

      The function to delay.

    • wait: number = 0

      The number of milliseconds to delay invocation.

    • Rest ...args: Parameters<T>

      The arguments to invoke func with.

      Rest

    Returns number

    Returns the timer id.

    Since

    5.7.0

    Example

    delay(text => console.log(text), 1000, 'later')
    // => Logs 'later' after one second.