I'm extending Transform, and I'm a little unclear when to 
call transform._transform(chunk, encoding, callback)'s callback.

The documentation says "Call the callback function only when the current 
chunk is completely consumed. Note that there may or may not be output as a 
result of any particular input chunk.". But what does "completely consumed" 
mean?

If I can't use the chunk yet (because I need to wait for more data for a 
full packet, and the packet's length has to be in the packet's header), and 
I keep a reference to the chunk, does that mean that I shouldn't call the 
callback yet? If that's the case, I guess that I need to keep the callback 
associated with each of these chunks.

    this._pendingChunks = [];
    ...
    this._pendingChunks.push({chunk: chunk, callback: callback});

Then I can call each chunk's callback (in a latter execution of _transform) 
when I've used it to create and push a complete packet, and I've no longer 
a need to reference the chunk.

Or am I making things more complicated than they need to be?

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
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].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to