Files: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3 / node_modules / pull-stream / throughs / through.js
473 bytesRaw
1 | |
2 | |
3 | //a pass through stream that doesn't change the value. |
4 | module.exports = function through (op, onEnd) { |
5 | var a = false |
6 | |
7 | function once (abort) { |
8 | if(a || !onEnd) return |
9 | a = true |
10 | onEnd(abort === true ? null : abort) |
11 | } |
12 | |
13 | return function (read) { |
14 | return function (end, cb) { |
15 | if(end) once(end) |
16 | return read(end, function (end, data) { |
17 | if(!end) op && op(data) |
18 | else once(end) |
19 | cb(end, data) |
20 | }) |
21 | } |
22 | } |
23 | } |
24 |
Built with git-ssb-web