Closed rejeep closed 10 years ago
just use a closure, like this:
var stream
return stream = through(function () {...},...)
even if you define write/end like you have, the value stream
will be set before either function is called (before the stream is returned) so you don't have to make a callback.
Also, write/end is called with this=stream so you can just do
through(function () {
this.queue(data)
})
It's better to use queue
than this.emit('data', data)
because then buffering on pause will work.
ust use a closure
Ahh, that works fine, thanks!
It's better to use queue than this.emit('data', data) because then buffering on pause will work.
Thanks for the tip!
Hi,
I am using through for building a Gulp task. I was writing my stream and ending up with the never ending
this/bind
hell. For example:To avoid the
bind
's, I created a function, let's call itthroughWithCallback
so that I could do this:As you see, the function is called with the
stream
(orthis
) as the first argument.What do you think about adding such a function to this library?