level-enumerate
v1.0.1
Published
Enumerate keys to incrementing numbers
Downloads
56
Readme
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
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