Skip to content

Commit

Permalink
Improved stream watermark and buffering.
Browse files Browse the repository at this point in the history
- Feedparser is a Transform stream that has a writable stream (ie. its input) that takes bytes, and a readable stream (ie. its output) that is in objectMode: how to achieve this difference is documented here: http://nodejs.org/api/stream.html#stream_state_objects
- In objectMode the watermark counts the number of buffered objects (and not the number of bytes), we need to reduce it as not to store 16k of fat JSON objects in memory.
  • Loading branch information
Paul Mougel committed Sep 25, 2013
1 parent bd74a78 commit 16e4f21
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ if (TransformStream === undefined) {
*/
function FeedParser (options) {
if (!(this instanceof FeedParser)) return new FeedParser(options);
TransformStream.call(this, {
objectMode: true
});
TransformStream.call(this);
this._readableState.objectMode = true;
this._readableState.highWaterMark = 100; // max. # of output nodes buffered

this.init();
this.parseOpts(options);
Expand Down

0 comments on commit 16e4f21

Please sign in to comment.