Created
May 8, 2013 23:47
-
-
Save mcollina/5544554 to your computer and use it in GitHub Desktop.
Error: cannot call next() after end()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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