git ssb

0+

dangerousbeans / patchbay-bootstrap



Tree: 96d0a60a7b7c41087f0c52c4ed0292f86ba7d4b1

Files: 96d0a60a7b7c41087f0c52c4ed0292f86ba7d4b1 / ui.js

649 bytesRaw
1var h = require('hyperscript')
2var pull = require('pull-stream')
3var u = require('./util')
4
5exports.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
25exports.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