Files: 134d423c26820a78c6bbfbc506df577e0673b6b2 / ui.js
649 bytesRaw
1 | var h = require('hyperscript') |
2 | var pull = require('pull-stream') |
3 | var u = require('./util') |
4 | |
5 | exports.createStream = function createStream (stream, render) { |
6 | var div = h('div.content') |
7 | |
8 | pull( |
9 | stream, |
10 | pull.drain(function (data) { |
11 | var el = render(data) |
12 | if('string' === typeof el) el = document.createTextNode(el) |
13 | if(el) { |
14 | if(div.children.length) |
15 | div.appendChild(h('hr')) |
16 | div.appendChild(el) |
17 | } |
18 | |
19 | }) |
20 | ) |
21 | |
22 | return div |
23 | } |
24 | |
25 | exports.createRenderers = function (renderers, sbot) { |
26 | return function (data) { |
27 | return u.first(renderers, function (fn) { |
28 | return fn(data, sbot) |
29 | }) |
30 | } |
31 | } |
32 |
Built with git-ssb-web