async-iteration-buffer

0.2.1 • Public • Published

async-iteration-buffer

A buffering tool for async iteration.

import { AsyncIterationBuffer } from 'async-iteration-buffer';

async function main() {
  let buffer = new AsyncIterationBuffer();

  // Insert a sequence of iteration results into the buffer
  buffer.next(1);
  buffer.next(2);
  buffer.next(3);
  buffer.return();

  // Pull the values out of the buffer by iterating over it
  for await (let value of buffer) {
    console.log(value);
  }
}

Install

npm install async-iteration-buffer

API

new AsyncIterationBuffer()

Creates a new buffer instance.

buffer.next(value)

Pushes a value into the iteration buffer.

buffer.throw(error)

Pushes an exception into the iteration buffer.

buffer.return(value)

Pushes a done result into the iteration buffer.

AsyncIterationBuffer.of(...values)

Creates a buffer pre-filled with the specified values

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.2.12latest

Version History

VersionDownloads (Last 7 Days)Published
0.2.12
0.2.00
0.1.20
0.1.10
0.1.00

Package Sidebar

Install

npm i async-iteration-buffer

Weekly Downloads

2

Version

0.2.1

License

MIT

Unpacked Size

6.24 kB

Total Files

5

Last publish

Collaborators

  • zenparsing