0.0.1 • Published 11 years ago

key-range v0.0.1

Weekly downloads
1
License
-
Repository
github
Last release
11 years ago

key-range

return whether a string key is within a levelup-style range

build status

testling badge

example

var range = require('key-range');
console.log(range('abc', { start: 'aaa', end: 'azz' }));
console.log(range('xyz', { lt: 'xyz' }));
console.log(range('gz', { gte: 'gz' }));
console.log(range('qrs', { gt: 'q', lt: 'r' }));

output:

true
false
true
true

methods

var range = require('key-range')

range(key, opts)

Return a boolean: whether the string key matches the range constraints given by opts.

opts may include any one of:

  • opts.start
  • opts.end
  • opts.lt
  • opts.lte
  • opts.gt
  • opts.gte
  • opts.min
  • opts.max

These correspond to the range options supported by levelup, although {lt,gt}{,e} is the preferred form.

install

With npm do:

npm install key-range

license

MIT