expose iterator with injected [Symbol.asyncIterator]
npm install levelup-async-iteratoriterator() to levelup that returns this._db.iterator(options) plus an injected [Symbol.asyncIterator] property
node --harmony_async_iteration example.js
`
import/require levelup-async-iterator on app entry;
`ts
import 'levelup-async-iterator';
import * as levelup from 'levelup';
import * as leveldown from 'leveldown';
import * as encode from 'encoding-down';
let db = levelup(encode(leveldown('./db')));
async function main() {
await db.put("a", "John");
await db.put("b", "James");
await db.put("c", "Janet");
await db.put("d", "Joseph");
let iter = db.iterator();
for await (let [key, value] of iter) {
if(key === "a"){
iter.it.seek("c");
}
console.log(key, value);
}
}
main();
`
output:
`
D:\Code\levelup-async-iterator>ts-node example
a John
c Janet
d Joseph
``
db.iterator() creates a iterator from the underlying store. the options parameter is the same as what you'd use for createReadStream