starry.generator-to-iterable

4.0.0 • Public • Published

Member of the starry suite—modular functions for iterable objects.

npm node

Status

Applies to the whole suite.

Build Status Coverage Status

Usage

function generatorToIterable<T = any>(
    generatorFn: () => Iterator<T>
  ): Iterable<T>

Wraps a generator function, or any function that returns an iterator, into an iterable such that #[Symbol.iterator]() runs the function.

Generator functions, as they turn out, do not save their initial state, and returns an iterator which just saves the generator's state. This function aims to remedy that problem.

Parameters:

  • generatorFn: () => Iterator<T> - A function that returns an iterator.

Returns: Iterable<T>

/starry.generator-to-iterable/

    Package Sidebar

    Install

    npm i starry.generator-to-iterable

    Weekly Downloads

    2

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    7.31 kB

    Total Files

    9

    Last publish

    Collaborators

    • seangenabe