mirror of
https://github.com/Instadapp/Swap-Aggregator-Subgraph.git
synced 2024-07-29 21:57:12 +00:00
24 lines
473 B
JavaScript
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)
|
|
})
|
|
}
|
|
}
|
|
}
|