This should probably be implemented as levelup's gte/lte/limit options instead.
var filter = through({objectMode: true}, function (record, encoding, cb) {
if (typeof record != "object") {
if (options.keys) record = {key: record}
if (options.values) record = {value: record}
// if both are true... wtf?
}
// split off version key & add it to record
var kv = unmakeKey(sep, record.key)
if (options.versionLimit) {
if (kv.key != this.currentKey) {
this.currentKey = kv.key
this.currentCount = 0
}
if (this.currentCount++ >= options.versionLimit) return cb()
}
if (kv.version >= options.minVersion && kv.version <= options.maxVersion) {
record.version = kv.version
record.key = kv.key
this.push(record)
}
cb()
})
|
var filter = through({objectMode: true}, function (record, encoding, cb) { |
|
if (typeof record != "object") { |
|
if (options.keys) record = {key: record} |
|
if (options.values) record = {value: record} |
|
// if both are true... wtf? |
|
} |
|
|
|
// split off version key & add it to record |
|
var kv = unmakeKey(sep, record.key) |
|
|
|
if (options.versionLimit) { |
|
if (kv.key != this.currentKey) { |
|
this.currentKey = kv.key |
|
this.currentCount = 0 |
|
} |
|
if (this.currentCount++ >= options.versionLimit) return cb() |
|
} |
|
|
|
if (kv.version >= options.minVersion && kv.version <= options.maxVersion) { |
|
record.version = kv.version |
|
record.key = kv.key |
|
this.push(record) |
|
} |
|
cb() |
|
}) |
This should probably be implemented as levelup's
gte/lte/limitoptions instead.level-version/index.js
Lines 186 to 210 in 0941eb7