@typedninja/flowable
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@typedninja/flowable

Async generators done right

Install

$ yarn add @typedninja/flowable

$ npm install --save @typedninja/flowable

Usage

See also the API documentation.

import { Flowable } from '@typedninja/flowable';

async function main (): Promise<void> {
  const iterable = new Flowable<number>(async (flow) => {
    let i = 0

    while (await flow.want() !== undefined) {
      flow.next(i++)
    }
  })

  for await (const i of iterable) {
    console.log(i)

    if (i >= 10) break
  }
}

main().catch(console.log)

License

MIT

Package Sidebar

Install

npm i @typedninja/flowable

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

13.6 kB

Total Files

17

Last publish

Collaborators

  • typedninja