Files: b4fc75e46531229d6deaed0dc3672ba2d5957460 / sinks.js
644 bytesRaw
1 | var 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 | |
11 | var 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 | |
18 | var 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 | |
26 | var log = exports.log = function (read) { |
27 | return drain(read, console.log.bind(console)) |
28 | } |
29 |
Built with git-ssb-web