git ssb

2+

Dominic / pull-stream



Tree: 22c80b9c74339096c81f7668440f2b298fad8116

Files: 22c80b9c74339096c81f7668440f2b298fad8116 / throughs / through.js

473 bytesRaw
1'use strict'
2
3//a pass through stream that doesn't change the value.
4module.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