mjijackson/bufferedstream — pull request #3 by jeffbski (2012-10-05 19:30:31+00:00)
Title: Prevent infinate loop when paused and never resumed

If a BufferedStream is created, paused, and content written to it via
constructor, write, or end without resume() ever being called,
BufferedStream will go into an infinate loop.

I created a test file you can run to verify. Without the fix, the test
never finishes and CPU hits 100%. With the fix the test
completes as expected.

The fix is to exit out of the process.next loops if it is paused
and then add triggers in resume() to do the work if necessary

Any of the following examples would have previously caused
an infinate loop if the stream was never resumed.

```javascript
var BufferedStream = require("./bufferedstream");

var bs1 = new BufferedStream('Hello world');
bs1.pause();

var bs2 = new BufferedStream('');
bs2.pause();

var bs3 = new BufferedStream();
bs3.pause();
bs3.write('Hello world');

var bs4 = new BufferedStream();
bs4.pause();
bs4.write('');

var bs5 = new BufferedStream();
bs5.pause();
bs5.end('Hello world');

var bs6 = new BufferedStream();
bs6.pause();
bs6.end('');
```