Skip to content

Instantly share code, notes, and snippets.

@ralphtheninja
Last active June 8, 2017 12:46
Show Gist options
  • Save ralphtheninja/879a79a4c92d170f9c21e098ed20ebe9 to your computer and use it in GitHub Desktop.
Save ralphtheninja/879a79a4c92d170f9c21e098ed20ebe9 to your computer and use it in GitHub Desktop.
some leveldown test files
// segfaults
var levelup = require('levelup')
var db = levelup('./test1.db')
db.put('foo', 'bar', { sync: true }, function (err) {
console.log('back from put', err)
})
db.close(function (err) {
console.log('closed the db', err)
})
// segfaults
var db = require('leveldown')('./test2.db')
var iterator = db.iterator()
// this should be extracted to a test file for leveldown, the stream _should_ error
const level = require('levelup')
const db = level('./test3.db')
const N = 10000
const batch = []
for (var i = 0; i < N; i++) {
batch.push({ type: 'put', key: i, value: 'a' })
}
db.batch(batch, function (err) {
if (err) throw err
db.createReadStream()
.once('data', function (data) {
db.close()
})
.on('error', function (err) {
console.log('readstream error')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment