What's wrong?
You'll find links to gists at the end of my post. The code works!
And Alexey's pumping function is equivalent to the pumping loop I gave in
my post.
On Saturday, October 13, 2012 7:31:54 PM UTC+2, Mikeal Rogers wrote:
>
> all of these are wrong.
>
> inputStream.pipe(outputStream)
> outputStream.on('close', callback)
>
> On Oct 13, 2012, at October 13, 20127:23 PM, Bruno Jouhier <
> [email protected] <javascript:>> wrote:
>
> I wrote a post about plain callback APIs for streams:
> http://bjouhier.wordpress.com/2012/07/04/node-js-stream-api-events-or-callbacks/
>
>
> On Saturday, October 13, 2012 11:17:13 AM UTC+2, Alexey Petrushin wrote:
>>
>> I don't quite understand how steam pause/resume works, or more exactly -
>> how to use it in simple manner. It's necessary to use it in situations when
>> the read stream produces data faster than the write stream can consume.
>>
>> I need to write custom stream implementation and writing it with proper
>> handling of `pause/resume` functionality seems not a very easy task.
>>
>> Plain callbacks seems simpler to me, can streams be somehow wrapped into
>> a code like that ( code with highlighting https://gist.github.com/3883920) ?
>>
>> var copy = function(inputStream, outputStream, callback){
>> var copyNextChunk = function(){
>> inputStream.read(fuction(err, chunk){
>> if(err) return callback(err)
>> // When chunk == null there's no data, copying is finished.
>> if(!chunk) return callback()
>> outputStream.write(chunk, function(err){
>> // Callback called only when chunk of data
>> // delivered to the recipient and
>> // we can send another one.
>> if(err) return callback(err)
>> copyNextChunk()
>> })
>> })
>> }
>> }
>>
>
> --
> 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] <javascript:>
> To unsubscribe from this group, send email to
> [email protected] <javascript:>
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
>
>
--
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