Yeah, you're probably doing way more than you need to.  Don't emit
anything, just create a `_read` function that calls `push(chunk)` and
do `push(null)` when there's no more data.  The Readable class takes
care of the rest!

On Sat, Mar 30, 2013 at 2:10 PM, Nathan Rajlich <[email protected]> wrote:
> When your Readable has ended, you gonna want to push a `null` chunk and the
> Readable machinery will emit "end" for you. Emitting "close" won't happen
> but that's not part of the readable stream interface anyways.
>
>
> On Sat, Mar 30, 2013 at 10:11 AM, Mark Volkmann <[email protected]>
> wrote:
>>
>> I implemented a simple Readable that provides Fibonacci numbers. It stops
>> when a given maximum value is passed or when the next value is
>> Number.POSITIVE_INFINITY. It's working great, but I want to make sure I did
>> everything that is expected. When it reaches the end I am emitting an 'end'
>> event and a 'close' event. I don't explicitly emit any other events. The
>> 'readable' event is emitted for me just by extending from stream.Readable
>> and pushing each value.
>>
>> Does it sound like I handled event emitting correctly?
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>> --
>> --
>> 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.
>>
>>
>
>
> --
> --
> 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.
>
>

-- 
-- 
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