Wraps iterator to allow for seeking backwards and forwards. An internal cache of length maxLength is kept and progressively added to when iterating forwards.

Type Parameters

  • T

Implements

  • IterableIterator<T>

Constructors

Properties

cache: T[] = []
i: number = 0
iterator: Iterator<T, any, undefined>
iteratorDone: boolean = false
maxLength: number = Infinity

Accessors

Methods

  • Parameters

    • Rest ...args: any[]

    Returns IteratorResult<T, any>

  • Peek ahead of where the current iteration is. This doesn't consume any values of the iterator.

    Type Parameters

    • N extends number = 1

    Parameters

    • ahead: N = ...

      optional, the number of elements to peek ahead.

    Returns Tuple<T, N>

  • Seeks forward/backwards to the index i. i may be any positive or negative number. Negative numbers seek starting from the end of the internal cache (e.g. -1 is the last element).

    Parameters

    • i: number

    Returns void