Why do you have to bind it?

Regards,
Ian

On Wednesday, August 14, 2013 at 11:55:31 PM UTC+2, Mathias Buus Madsen 
wrote:
>
> Usually when I pipe streams I want to destroy the source if the 
> destination closes.
> Since pipe does not do that I kept repeating this
>
> source
> .on('close', dest.destroy.bind(dest))
> .on('error', dest.destroy.bind(dest))
> .pipe(dest)
> .on('close', source.destroy.bind(source))
> .on('error', source.destroy.bind(source))
>
> I decided to do a small module that does this for me. It is called pump
>
> https://github.com/mafintosh/pump
>
> Using pump you can do the above like so
>
> var pump = require('pump');
> pump(source, transform1, transform2, ..., dest, function(err) {
>  console.log('pipe finished', err);
> });
>
> It works with both 0.8 and 0.10 streams.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/e9f0f6cf-2e8b-4325-bc1c-fff28c74305e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to