-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkey-range.js
More file actions
20 lines (17 loc) · 758 Bytes
/
key-range.js
File metadata and controls
20 lines (17 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* global IDBKeyRange */
'use strict'
module.exports = function createKeyRange (options) {
const lower = options.gte !== undefined ? options.gte : options.gt !== undefined ? options.gt : undefined
const upper = options.lte !== undefined ? options.lte : options.lt !== undefined ? options.lt : undefined
const lowerExclusive = options.gte === undefined
const upperExclusive = options.lte === undefined
if (lower !== undefined && upper !== undefined) {
return IDBKeyRange.bound(lower, upper, lowerExclusive, upperExclusive)
} else if (lower !== undefined) {
return IDBKeyRange.lowerBound(lower, lowerExclusive)
} else if (upper !== undefined) {
return IDBKeyRange.upperBound(upper, upperExclusive)
} else {
return null
}
}