Swap-Aggregator-Subgraph/node_modules/pull-stream/throughs/through.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

24 lines
473 B
JavaScript

'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)
})
}
}
}