Function cancel

  • Cancels a generator by calling its return method and handles rescheduling if it yields in finally. Prefer this over calling return directly.

    Parameters

    • gen: Generator<any, any, any>

      Generator to cancel

    • Optional resume: Generator<any, any, any> = gen

      Generator to resume if cancellation yields, used internally.

    Returns IteratorResult<any, any>

    The result from calling return