Skip to content

Instantly share code, notes, and snippets.

@mcollina
Created May 8, 2013 23:47
Show Gist options
  • Save mcollina/5544554 to your computer and use it in GitHub Desktop.
Save mcollina/5544554 to your computer and use it in GitHub Desktop.
Error: cannot call next() after end()
var leveldown = require("leveldown")
, db = leveldown("./db")
, async = require("async")
, count = 0
, iterators = []
, mythrow = function(err) {
console.log(err)
}
async.series([
function(cb) {
db.open(cb)
},
function(cb) {
async.whilst(
function() { return count < 100 },
function(callback) {
count++;
db.put("a" + count, "b" + count, callback);
},
cb
)
},
function(cb) {
iterators.push(db.iterator())
db.close(cb)
},
function(cb) {
iterators.forEach(function(i) {
i.next(mythrow)
})
cb()
},
function(cb) {
console.log("done!")
cb()
}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment