level-enumerate
Enumerate keys to incrementing numbers
Last updated 10 years ago by mafintosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install level-enumerate 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.1                                ...           latest (10 years ago)

2 Versions

  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |