Re: [nodejs] Re: Stream to JSON

2012-05-27 Thread Mikeal Rogers
Max did a pretty good writeup. http://maxogden.com/node-streams On May 27, 2012, at May 27, 20124:31 PM, Tim Dickinson wrote: > Anything else you can think of? I don't really understand now the streams > should end. > > On Sunday, May 27, 2012 7:23:10 PM UTC-4, Mikeal Rogers wrote: > these are

Re: [nodejs] Re: Stream to JSON

2012-05-27 Thread Tim Dickinson
Anything else you can think of? I don't really understand now the streams should end. On Sunday, May 27, 2012 7:23:10 PM UTC-4, Mikeal Rogers wrote: > > these are both read/write streams but you don't appear to be emitting > "end" after end() is called. that's an issue. > > On May 27, 2012, at M

Re: [nodejs] Re: Stream to JSON

2012-05-27 Thread Mikeal Rogers
these are both read/write streams but you don't appear to be emitting "end" after end() is called. that's an issue. On May 27, 2012, at May 27, 20124:19 PM, Tim Dickinson wrote: > So I thought about what you had said and I came up with this > https://gist.github.com/2816361. What tips can you

[nodejs] Re: Stream to JSON

2012-05-27 Thread Tim Dickinson
So I thought about what you had said and I came up with this https://gist.github.com/2816361. What tips can you give me if any on making the "Stream"'s? On Monday, April 30, 2012 6:36:22 PM UTC-4, Marco Rogers wrote: > > There are several potential issues I'm seeing here. But it looks like you

Re: [nodejs] Re: Stream to JSON

2012-04-30 Thread Oliver Leics
Oh, there is a shortcut to send the mail :D The Lazy module: https://github.com/pkrumins/node-lazy A gist showing some fun stuff to do with Lazy: https://gist.github.com/2521280 On Tue, May 1, 2012 at 12:51 AM, Oliver Leics wrote: > var decryptedStream = decryptStream(socket) > > decryptedStrea

Re: [nodejs] Re: Stream to JSON

2012-04-30 Thread Oliver Leics
var decryptedStream = decryptStream(socket) decryptedStream.on('data', function(d) { }) function decryptStream(socket) { var s = createStream() Lazy(socket) .lines .map(String) .forEach(function(d) { // d is one line of data s.emit('data', decrypt(d)) }) retu

[nodejs] Re: Stream to JSON

2012-04-30 Thread Tim Dickinson
Oh i like that idea. If i did it like you had said then i would maybe pipe to a xml praser or pipe even to a logger. On Monday, April 30, 2012 6:36:22 PM UTC-4, Marco Rogers wrote: > > There are several potential issues I'm seeing here. But it looks like you > have an incoming stream of json mes

[nodejs] Re: Stream to JSON

2012-04-30 Thread Marco Rogers
There are several potential issues I'm seeing here. But it looks like you have an incoming stream of json messages that are encrypted and separated by newlines. You want parse the stream, decrypt each message and then pass the message to a data handler that expect to each message one by one. Is

[nodejs] Re: Stream to JSON

2012-04-30 Thread Tim Dickinson
Oh sorry and you would use it like so socket.on('data', bufferJson(key, function(data) { //do something with json object })) On Monday, April 30, 2012 6:23:11 PM UTC-4, Tim Dickinson wrote: > > Hey all. > > How can i better write this snippet of code? > > var bufferJson = function(key, requestEv