Files: fe399b8ac15da7a6c0cae09a3d9cfa47ac11818e / indexes / feed.js
869 bytesRaw
1 | var Follower = require('../follower') |
2 | var pull = require('pull-stream') |
3 | var path = require('path') |
4 | var ltgt = require('ltgt') |
5 | var u = require('../util') |
6 | |
7 | module.exports = function (db) { |
8 | |
9 | var indexPath = path.join(db.location, 'feed') |
10 | var index = Follower(db, indexPath, 1, function (data) { |
11 | if(data.sync) return |
12 | return { |
13 | key: [data.value.timestamp, data.value.author], |
14 | value: data.key, type: 'put' |
15 | } |
16 | }) |
17 | |
18 | index.createFeedStream = function (opts) { |
19 | opts = u.options(opts) |
20 | //mutates opts |
21 | ltgt.toLtgt(opts, opts, function (value) { |
22 | return [value, u.lo] |
23 | }, u.lo, u.hi) |
24 | |
25 | var _keys = opts.keys |
26 | var _values = opts.values |
27 | opts.keys = false |
28 | opts.values = true |
29 | |
30 | return pull( |
31 | index.read(opts), |
32 | pull.through(console.log), |
33 | db.lookup(_keys, _values) //XXX |
34 | ) |
35 | } |
36 | |
37 | return index |
38 | |
39 | } |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 |
Built with git-ssb-web