git ssb

3+

arj / patchbook



Tree: b3369beb8b305b3fd5c63b483fdd8810799b0e2d

Files: b3369beb8b305b3fd5c63b483fdd8810799b0e2d / book / obs / book.js

556 bytesRaw
1const nest = require('depnest')
2const ref = require('ssb-ref')
3const { Value, Struct } = require('mutant')
4
5exports.needs = nest({
6 'book.pull.get': 'first',
7 'blob.sync.url': 'first'
8})
9
10exports.gives = nest('book.obs.book')
11
12exports.create = function (api) {
13 return nest('book.obs.book', function (id) {
14 if (!ref.isLink(id)) throw new Error('a valid id must be specified')
15
16 let book = api.book.pull.get(id)
17 const s = Struct()
18
19 Object.keys(book).forEach(k => {
20 if (book[k])
21 s[k].set(book[k])
22 })
23
24 return s
25 })
26}
27

Built with git-ssb-web