Commit Graph

21 Commits (60238cce12d5c0c45c54c18033a439ac12429a29)

Author SHA1 Message Date
isaacs 33b2aebb6d stream: Writable should ignore encoding for buffers
Fix #4727
Fix einaros/ws#159
2013-02-07 08:50:18 -08:00
Nathan Rajlich a9c4a20331 stream: make Writable#end() accept a callback function
This is more backwards-compatible with stream1 streams like `fs.WriteStream`
which would allow a callback function to be passed in as the only argument.

Closes #4719.
2013-02-05 15:12:06 -08:00
Raynos 444bbd4fa7 streams: Support objects other than Buffers
We detect for non-string and non-buffer values in onread and
turn the stream into an "objectMode" stream.

If we are in "objectMode" mode then howMuchToRead will
always return 1, state.length will always have 1 appended
to it when there is a new item and fromList always takes
the first value from the list.

This means that for object streams, the n in read(n) is
ignored and read() will always return a single value

Fixed a bug with unpipe where the pipe would break because
the flowing state was not reset to false.

Fixed a bug with sync cb(null, null) in _read which would
forget to end the readable stream
2013-01-24 07:49:27 -08:00
isaacs 20a3c5d09c streams2: Do not allow hwm < lwm
There was previously an assert() in there, but this part of the code is
so high-volume that the added cost made a measurable dent in http_simple.

Just checking inline is fine, though, and prevents a lot of potential
hazards.
2013-01-14 16:03:38 -08:00
isaacs f9caf7020c streams: Speed up by doing less work in the state ctors 2012-12-21 00:07:34 +00:00
isaacs 9f4c0988c3 streams2: Process write buffer in a loop, not recursively
This fixes pummel/test-net-write-callbacks
2012-12-19 10:55:23 -08:00
isaacs f63af64eb8 test-pummel: Add call validation in net-write-callbacks 2012-12-19 10:55:23 -08:00
isaacs 82c7c84e25 net: Handle sync writable streams synchronously
This fixes the case where stderr doesn't flush before the process exits.
2012-12-17 15:08:57 -08:00
isaacs 3751c0fe40 streams2: Still emit error if there was a write() cb 2012-12-14 17:46:23 -08:00
isaacs 5760244cc6 streams2: Writable only emit 'finish' once 2012-12-14 10:52:28 -08:00
isaacs b15e19a232 streams2: Remove function.bind() usage
It's too slow, unfortunately.
2012-12-13 17:00:32 -08:00
isaacs 0118584433 streams2: Writable organization, add 'finishing' flag 2012-12-13 17:00:31 -08:00
isaacs 63ac07b32b streams2: Export Readable/Writable State classes 2012-12-13 17:00:30 -08:00
isaacs e82d06bef9 streams2: Fix regression from Duplex ctor assignment 2012-12-13 17:00:28 -08:00
isaacs 71e2b61388 streams2: Support write(chunk,[encoding],[callback]) 2012-12-13 17:00:27 -08:00
isaacs 0678480b57 streams2: Allow Writables to opt out of pre-buffer-izing 2012-12-13 17:00:27 -08:00
isaacs 545f512619 streams2: ctor guards on Stream classes 2012-12-13 17:00:26 -08:00
isaacs 06e321d0f9 streams2: Correct drain/return logic
It was testing the length *before* adding the current chunk, which
is the opposite of correct.

Also, the return value was flipped.
2012-12-13 17:00:25 -08:00
isaacs 02f017d24f streams2: Allow 0 as a lowWaterMark value 2012-12-13 17:00:25 -08:00
isaacs 639fbe28d1 streams2: Convert strings to buffers before passing to _write() 2012-12-13 17:00:23 -08:00
isaacs 420e07c577 streams2: The new stream base classes 2012-12-13 17:00:23 -08:00