npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

level-enumerate

1.0.1

@mafintosh

npmHomeRepoSnykSocket
Downloads:0
$ npm install level-enumerate
DailyWeeklyMonthlyYearly

level-enumerate

Enumerate keys to incrementing numbers. If you enumerate the same key twice it will enumerate to the same value.

npm install level-enumerate

build status

Usage

var enumerator = require('level-enumerate')
var enumerate = enumerator(db) // where db is a levelup

enumerate('hello', function (err, value) {
  console.log(value) // prints 0
  enumerate('hello', function (err, value) {
    console.log(value) // prints 0 again
    enumerate('world', function (err, value) {
      console.log(value) // prints 1
    })
  })
})

API

enumerate = enumerator(db, [options])

Create a new enumerator. Options include

{
  sep: '!'    // the separator used when storing the key values
  prefix: ... // optional string prefix to use when keys when stored
}

License

MIT