Feature: iterator/generator based output as alternative to streams
Created by: rijnhard
Streams are a nice interface to handling larger amounts of query data. but streams are fairly verbose to implement, especially if you do the error handling and backpressure properly.
Generators are a much more familiar interface, and much simpler in the use case
e.g. using async iterators (which aren't standard yet)
async function processQueued() {
const iterator = b.tests.find({priority: 'low'}, {iterator: true});
for await (const item of iterator) {
await doRandomProcess(item);
}
}
This is much simpler then handling streams, the only real drawback is that async generators are not standard yet, but if resolving a promise with an iterator is sufficient then this isn't an issue.