Skip to content

Conversation

@dominictarr
Copy link

you need this stuff as well.

Also, two other small corrections, return dest, and check written === false instead of !written
which is consistent with the current pipe, and documentation.

with this stuff in the pipe is about the same length,
I suggest we just test for read()

if ('function' === typeof source.read) {
  //use read() still piping
  ...
} else {
  //use ondata style
  ...
}

best of both worlds

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be if (written === false) { ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, your right. fixed in a17850dd4ef3d86ba2f062a91f3a5300a4b1b4b6

@isaacs
Copy link
Contributor

isaacs commented Jul 30, 2012

Only 'end' means "no more bytes are coming so stop reading". "close" means "the underlying resource is disposed of" but there may be more bytes in the buffer. For example, if a fs stream has a buffering window of 16kb, but closes the fd as soon as it stops getting more stuff; the fd is now closed, but the stream isn't ended, because read() can still give you more data.

For errors, they should be handled at every step along the way, by the code that touches that stream.

So, I think this is not really necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants