Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

vweevers/level-iterator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

decoding iterator for levelup instances

Resources

License

Stars

Watchers

Forks

Packages

No packages published