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