generate and parse string key-ranges (for use with levelup)
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
test
.gitignore
.travis.yml
LICENSE
README.md
index.js
package.json

README.md

range-bucket

Generate string ranges that group into ranges, suitable for use as database keys (recommended for levelup)

var bucket = require('range-bucket')
//will create buckets that are prefixed with BUCKET.
var b = bucket('BUCKET')
var b2 = bucket('BUCKET2')

var keys = []

keys.push(b('hello'))
keys.push(b('goodbye'))

keys.push(b2('bonjour'))

//get the range defined by a bucket like this:
b.range()

//fiter a range like this:

console.log(
 keys.filter(b.range().within)
)

//optionally, pass in start and end keys to restrict the range.

console.log(
 keys.filter(b.range('', 'h').within)
)

License

MIT