Interface CreateIteratorContext<T>

The context used to manage how the createIterator returns and moves to the next item, and provides to the current value v.

0.4.2

interface CreateIteratorContext<T> {
    n: ((...args: any) => boolean);
    r?: ((value?: T) => T);
    t?: ((e?: any) => T);
    v?: T;
}

Type Parameters

  • T

Properties

Properties

n: ((...args: any) => boolean)

A function that returns a boolean to indicate whether it was able to produce the next value in the sequence. It should return true when the sequence is done.

Type declaration

    • (...args): boolean
    • Parameters

      • Rest...args: any

        Optional additional arguments that where passed to the iterator next function.

      Returns boolean

      false if a new value was produced and assigned to the v of the context, otherwise true to indicate that the sequence is done.

r?: ((value?: T) => T)

Optional function that accepts zero or one argument. This function is called via the iterator return function when the iterator caller does not intend to make any more next() calls so the implementation and can perform any cleanup actions.

Type declaration

    • (value?): T
    • Parameters

      • Optionalvalue: T

      Returns T

      [Optional] value to be included in the final iteration result

t?: ((e?: any) => T)

A function that accepts zero or one argument. The function is called via the iterator throw function when that the iterator caller detects an error condition, and e is typically an Error instance.

Type declaration

    • (e?): T
    • Parameters

      • Optionale: any

      Returns T

      [Optional] value to be included in the final iteration result

v?: T

The current value to be assigned to the returned iterator result, the next n function should assign this value to the context as part of incrementing to the next value.