-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
28 lines (24 loc) · 890 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var isNumber = function (n) { return 'number' === typeof n }
var isObject = function (o) { return o && 'object' === typeof o && !isArray(o) }
var isArray = Array.isArray
var Indexes = require('./indexes')
var Inject = require('./inject')
module.exports = function (version, opts) {
if(!isNumber(version)) throw new Error('flumeview-query:version expected as first arg')
if(!isObject(opts)) throw new Error('flumeview-query: expected opts as second arg')
return function (log, name) {
if(!log.filename) return require('./memory')(log, name)
var _view = Indexes(version, opts)(log, name)
var view = Inject(log, _view.indexes())
view.methods = {
read: 'source',
add: 'sync',
explain: 'sync'
}
view.createSink = _view.createSink
view.since = _view.since
view.close = _view.close
view.destroy = _view.destroy
return view
}
}