BTW, there's now a `Buffer.concat` <https://nodejs.org/api/buffer.html#buffer_class_method_buffer_concat_list_totallength> built in.
On Saturday, March 5, 2011 at 11:26:04 AM UTC-8, Sean Hess wrote: > > Cool. Thanks all > > On Mar 2, 6:52 pm, AJ ONeal <[email protected]> wrote: > > Yep > > > > https://github.com/coolaj86/node-bufferjs > > > > npm install bufferjs > > > > require('bufferjs') > > > > Buffer.concat(arrayOfBuffers); > > > > AJ ONeal > > (317) 426-6525 > > > > > > > > > > > > > > > > On Wed, Mar 2, 2011 at 5:35 PM, Tim Caswell <[email protected]> > wrote: > > > Buffers can't be resized. What I often do is collect an array of > buffer > > > objects and then at the end, loop over them to get the total size, > create a > > > new buffer, and then loop again copying the buffers into their > respective > > > slots in the big buffer. > > > > > On Wed, Mar 2, 2011 at 4:20 PM, Sean Clark Hess > > > <[email protected]>wrote: > > > > > >> When downloading something over http, it's usually easier to collect > > >> all the data from the request and return it all at once. > > > > >> For example, if the http request returns a string, you can do > > >> something like this: > > > > >> request.on('response', function(response) { > > >> var data = "" > > >> response.on('data', function(chunk) { > > >> data += chunk > > >> }) > > > > >> response.on('end', function() { > > >> callback(data) > > >> }) > > >> }) > > > > >> How can I do the same thing for binary data? Like, if I'm downloading > > >> an image? I'm using node v0.2.6 > > > > >> Thanks > > >> ~sean > > > > >> -- > > >> 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. > > > > > -- > > > 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. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/5379bd70-665e-4085-bd44-e46760a2f2f9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
