Function defer

  • Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.

    Type Parameters

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

    Parameters

    • func: F

      The function to defer.

    • Rest ...args: Parameters<F>

      The arguments to invoke func with.

      Rest

    Returns number

    Returns the timer id.

    Since

    5.7.0

    Example

    defer(text => console.log(text), 'deferred')
    // => Logs 'deferred' after one millisecond.