git ssb

2+

Dominic / pull-stream



Tree: f2094a0360975cb77c09e9635cf7ce2801178945

Files: f2094a0360975cb77c09e9635cf7ce2801178945 / 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