-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (34 loc) · 708 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Dependencies
*/
const engine = require('trumpet')
const Readable = require('stream').Readable
/**
* Expose 'content' to be used primarly
* with sa declarative syntax
* @see https://github.com/bredele/steroid-hook
*/
module.exports = slot
/**
*
*/
function slot(params) {
return slot.query(params.name, params.from)
}
/**
*
*
*/
slot.query = function(selector, source) {
const query = engine()
const dest = new Readable
dest._read = function(){}
query.selectAll(`[slot="${selector}"]`, function (el) {
el.createReadStream({
outer: true
}).on('data', data => dest.push(data))
})
query.on('end', () => dest.push(null))
source.pipe(query)
return dest
}