ts-iterable-functions
    Preparing search index...

    Function toIterable

    • Wraps a generator function to provide an iterable object with additional functionality.

      The returned object implements the Iterable protocol using the provided generator function, and also provides a toJSON method that returns all generated values as an array, meaning that JSON.stringify will work as expected.

      Type Parameters

      • T

        The type of elements produced by the generator function.

      • TF extends () => IterableIterator<T>

        The type of the generator function, which returns an IterableIterator<T>.

      Parameters

      • f: TF

        A generator function that returns an IterableIterator<T>.

      Returns { "[iterator]": TF; toJSON(): T[] }

      An object implementing Iterable<T> and a toJSON method for serialization.