git ssb

2+

Dominic / pull-stream



Tree: b4fc75e46531229d6deaed0dc3672ba2d5957460

Files: b4fc75e46531229d6deaed0dc3672ba2d5957460 / sinks.js

644 bytesRaw
1var writeArray = exports.writeArray = function (read, cb) {
2 var array = []
3 read(null, function next (end, data) {
4 if(end)
5 return cb(end === true ? null : end, array)
6 array.push(data)
7 read(null, next)
8 })
9}
10
11var onEnd = exports.onEnd = function (read, done) {
12 return read(null, function next (err, data) {
13 if(err) return done(err)
14 read(null, next)
15 })
16}
17
18var drain = exports.drain = function (read, op) {
19 return read(null, function next (err, data) {
20 if(err) return
21 op && op(data)
22 read(null, next)
23 })
24}
25
26var log = exports.log = function (read) {
27 return drain(read, console.log.bind(console))
28}
29

Built with git-ssb-web