git ssb

2+

Dominic / pull-stream



Tree: c4caefd7c6cd6984ee0223c391cd4ce43118cf29

Files: c4caefd7c6cd6984ee0223c391cd4ce43118cf29 / sinks.js

680 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, done) {
19 return read(null, function next (err, data) {
20 if(err) return done && done(err)
21 op && op(data)
22 read(null, next)
23 })
24}
25
26var log = exports.log = function (read, done) {
27 return drain(read, console.log.bind(console), done)
28}
29

Built with git-ssb-web