Munter / pipetteur

A function to extract any colors from a string
11 stars 1 forks source link

Work with pipes #1

Open tvooo opened 10 years ago

tvooo commented 10 years ago

Great work, Peter. Do you have any plans to make this work with pipes as well? Each colour found could be emitted through an event.

Munter commented 10 years ago

That would certainly make sense. I haven't done that much work with pipes yet, so I'm not 100% certain on how to do that. Do you have an existing module that works in a similar fashion I could take a peek at?

Munter commented 10 years ago

Possible things that would have to be considered:

tvooo commented 10 years ago

Ah, by "pipe" I of course mean "stream"; that's the correct Node terminology. There are modules that look for a string in a stream, for example https://github.com/mscdex/streamsearch (but you should always look at the performance as well). However, if you are using regexes, take a look at https://www.npmjs.org/package/regex-stream - I just found it, looks promising. Maybe not for direct use, as it seems to create JS objects in an opinionated way, but you can look at how it works.