implement correct ranges for level-*
npm install ltgtimplement correct ranges for level-*


`` js
var ltgt = require('ltgt')
ltgt.start(range) //the start of the range
ltgt.end(range) //the end of the range
//returns the lower/upper bound, whether it's inclusive or not.
ltgt.lowerBound(range)
ltgt.upperBound(range)
ltgt.lt(range)
ltgt.gt(range)
ltgt.lte(range)
ltgt.gte(range)
//return wether this is a reversed order
//(this is significant for start/end ranges
ltgt.reverse(range)
var filter = ltgt.filter(range)
filter(key) == true //if key contained in range.
ltgt.contains(range, key)
`
there have been a variety of ways to specify ranges in level-*.
this module supports them all.
specify a range between a lower bound (gt, gte) and an upper bound (lt, lte)
if gte and gt is undefined, read from the start of the database,lte
if and lt is undefined, read until the end of the database,
legacy level-sublevel style,
synonym for gte, lte.
legacy levelup style.
The range is from start -> end, start does not specify the lowestreverse
record, instead it specifies the first record to be read. However, must also be passed correctly. This is way to specify a range isgt/gte,lt/lte
confusing if you need to read in reverse,
so it's strongly recommended to use .
If reverse is true,start must be undefined or less than end,end
unless is undefined.
if reverse is falseend must be undefined or greater than start,start
unless is undefined.
if start is undefined, read from the first record in the database
if end is undefined read until the last record in the database.
using the provided compare method, return true if keyrange
is within . compare defaults to ltgt.compare
return a function that returns true if it's argument is within range.
can be passed to Array.filter
` js`
[1,2,3,4,5].filter(ltgt.filter({gt: 2, lte: 4})
// => [3, 4]
return the lower bound of range.gt
Incase the lower bound is specified with ,ltgt.lowerBoundExclusive
check
return the upperBound of range.gt
Incase the upper bound is specified with ,ltgt.upperBoundExclusive
check
return true if upper bound is exclusive.
return true if lower bound is exclusive.
The start of the range. This takes into account direction (reverse)
If a start is not provided, default is used.
The end of the range. This takes into account direction (reverse)
If a end is not provided, default is used.
returns true if the range should start at the exact value returned
by start(range) otherwise, it should skip one input.
returns true if the range should include the exact value returned
by end(range) otherwise, it should end on that value.
convert a range to a new ltgt range. _rangerange
is the object to return - if you want to mutate ltgt.toLtgt(range, range, map)
call
map gets called on each key in the range, and wether it's an upper or lower bound -
so can be used as an encode function.
map(value, isUpperBound) if isUpperBound` is false, this is the lower bound.
MIT