Function itr8FromImpureFunction

  • Turns a parameterless function into an Iterator that will produce results using the input function's return value. In case the function returns a promise, the result will be an AsyncIterator. Useful for 'impure' stuff like Math.random, or Date.now etc.

    Example

    pipe(
    itr8FromImpureFunction(Math.random),
    take(3),
    itr8ToArray
    ); // => [0.2511072995514807, 0.04918679946517224, 0.48479881173432826]

    Returns

    an iterator

    Type Parameters

    • T

    Parameters

    • f: (() => T | Promise<T>)
        • (): T | Promise<T>
        • Returns T | Promise<T>

    Returns IterableIterator<T> | AsyncIterableIterator<T>

Generated using TypeDoc