Re: [nodejs] handling streams in native c++ addons

2013-10-23 Thread Duncan Wong
Sorry for digging up an old post I'm thinking about writing a C++ streaming json parser addon. The implementations I've found so far are done in javascript and are perhaps much slower than buffering the full response and doing JSON.parse (a couple of streaming json authors say that the speed i

Re: [nodejs] handling streams in native c++ addons

2012-04-15 Thread Nathan Rajlich
I second Isaac's recommendation. That is exactly how the Encoderclass in node-lame is written. Essentially the C bindings are 1-1 mappings to the C functions themselves. Then creating the

Re: [nodejs] handling streams in native c++ addons

2012-04-15 Thread Isaac Schlueter
I'd recommend not doing the "stream" bit in C++, and instead have a much simpler binding layer that does a single action, and then use JavaScript to wrap up the queue of writes and emitted data blobs. Check out the zlib binding in src/node_zlib.cc and lib/zlib.js in node's source. It does somethi

[nodejs] handling streams in native c++ addons

2012-04-15 Thread rhasson
I'm working on a C++ NLP binding and wanted to implemented a streaming interface so that text could be added to a stream in JS, my native binding will receive it, extract the text process it and emit a "data"events with the responses. How would I go about reading a stream that was either passed