Files: adc35583fed37c181f0cebd5b2509ff6d4973cf2 / sinks.js
487 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 drain = exports.drain = function (read, op) { |
12 | return read(null, function next (err, data) { |
13 | if(err) return |
14 | op && op(data) |
15 | read(null, next) |
16 | }) |
17 | } |
18 | |
19 | var log = exports.log = function (read) { |
20 | return drain(read, console.log.bind(console)) |
21 | } |
22 |
Built with git-ssb-web