This class caches iterator values until the cache is marked out of date.

This is very useful if the iteration is expensive and you know when new values have arrived.

Type Parameters

  • T

Constructors

  • Construct a new cache.

    Type Parameters

    • T

    Parameters

    • createIterator: (() => AsyncIterableIterator<T>)

      This callback creates a new iterator that is used to fill the cache.

        • (): AsyncIterableIterator<T>
        • Returns AsyncIterableIterator<T>

    • incrementalUpdates: boolean = false

      This is an optimization that will update the cache by appending new values at the end of the cache. The prerequisites for activating this feature are:

      • In a complete iteration of a new iterator all values need to be unique. The iterator is not allowed to return the same element twice.
      • New elements must appear at the beginning of the iteration and the previous elements need to stay the same. This way the iteration can stop as soon as an element, that is already in the cache, is encountered.

    Returns IteratorValueCache<T>

Methods