0.0.2 • Published 8 years ago

level-iterator v0.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

level-iterator

Decoding iterator for levelup instances. Wraps *DOWN iterators like level-iterator-stream does. For when you want speed and can do without backpressure and other stream features.

npm status Travis build status AppVeyor build status Dependency status

example

const iterator = require('level-iterator')
const disk = require('test-level')({ clean: true, encoding: 'json' })

const db = disk()

db.batch([
  { key: 1, value: 1 },
  { key: 2, value: 2 },
  { key: 3, value: 3 }
], function(err) {
  // Bypass value decoding
  const iter = iterator(db, { gt: 2, values: false })

  iter.next(function(err, key, value){
    console.log(typeof key, key === 3, value) // number true null

    // Don't forget to call end()
    iter.end(function(){
      console.log('done')
    })
  })
})

iterator(db[,opts])

  • db must be a levelup db
  • opts is all the usual stuff (keys, values, limit, ltgt, encoding, ..)

install

With npm do:

npm install level-iterator

license

MIT © Vincent Weevers