this is cool. I like the stream transformation. And it seems easier to
write than a bunch of streams you'd pipe together.
I made a few of these in my days
https://github.com/Floby/node-json-streams
https://github.com/Floby/node-parser
https://github.com/Floby/node-tokenizer
On Sep 19, 5:27 am, Dominic Tarr <
dominic.t...@gmail.com> wrote:
> yes, that would be a natural application of it.
>
> event-stream has a function that rechunks the stream on newlines, but you
> could rechunk on word boundries also, and then just pipe into lucene.
>
> isn't lucene written in java? how do you connect it to node?
>
> On Mon, Sep 19, 2011 at 12:23 AM, Richard Marr <
richard.m...@gmail.com>wrote:
>
>
>
>
>
>
>
> > On 18 September 2011 11:34, Dominic Tarr <
dominic.t...@gmail.com> wrote:
>
> > > connect lets you join streams like middle ware:
>
> > Like it a lot. The first thing that hit me when looking at this was the
> > TokenStream model in Lucene. I feel an experiment coming on.
>
> > On 18 September 2011 11:34, Dominic Tarr <
dominic.t...@gmail.com> wrote:
>
> >> hey every one!
>
> >> I think I've leveled up at node recently, and one of the new moves I've
> >> gained is how to use streams.
>
> >> Streams are AWESOME, they are one of the best things about node, yet, not
> >> many people are using them.
>
> >> Streams can be used for more than just input and output, streams can also
> >> be used for *throughput! *
> >> which is a great idea, because streams have a naturally scalable API.
>
> >>
https://github.com/dominictarr/event-stream
>
> >> npm install event-stream
>
> >> you can do things like this:
>
> >> es.map(function (data, callback) {
> >> callback(null, data)
> >> })
>
> >> this would transform a stream of file names into a stream of file Stats:
>
> >> es.map(fs.stat)
>
> >> connect lets you join streams like middle ware:
> >> var connected =
> >> es.connect(
> >> process.openStdin(),
> >> es.split(), //break by /n
> >> es.map(fs.stat),
> >> es.map(function (d.cb) { callback(null, JSON.stringify(d) + '/n') }),
> >> process.stdout
> >> )
> >> *
> >> *
> >> the advantage this has over using `pipe` it that it returns a single
> >> stream that is composed of a bunch of streams, but still acts like one *through
> >> stream* (a stream that is both readable and writable)