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);
}
}
npm install async-iteration-buffer
Creates a new buffer instance.
Pushes a value into the iteration buffer.
Pushes an exception into the iteration buffer.
Pushes a done
result into the iteration buffer.
Creates a buffer pre-filled with the specified values