Function delay

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

    Type Parameters

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


    • 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.

    Returns number

    Returns the timer id.


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