You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
473 B

'use strict'
//a pass through stream that doesn't change the value.
module.exports = function through (op, onEnd) {
var a = false
function once (abort) {
if(a || !onEnd) return
a = true
onEnd(abort === true ? null : abort)
}
return function (read) {
return function (end, cb) {
if(end) once(end)
return read(end, function (end, data) {
if(!end) op && op(data)
else once(end)
cb(end, data)
})
}
}
}