make it writable stream?
Is there any reason why you use push('chunk') as an api instead of write?
I'd like to be able to use search as a stream:
var cmd = cp.spawn(...);
var s = new StreamSearch('some text');
cmd.stdout.pipe(s);
cmd.stdout.pipe(process.stdout);
s.once('info', function(info) {
console.log(info);
});
:+1: to this!
The reason is that it was originally written in 2012, well before streams2 and when writing a stream implementation by hand was a pain :-)
Here is a hacky solution for this:
var cmd = cp.spawn(...);
var s = new StreamSearch('some text');
s.write = s.end = s.push.bind(s);
cmd.stdout.pipe(s);
cmd.stdout.pipe(process.stdout);
s.once('info', function(info) {
console.log(info);
});
@mscdex would you accept a PR to make it a writable stream?
Would rather wish for something that's more based upon iterators that's more node/deno/browser friendlier. no need to involve NodeJS streams.
for (const chunk of new StreamSearch(iterable)) {
...
}
Also would prefer Uint8array instead of using node Buffer
I forked and swapped out Buffer for Uint8Array and added web streams (i.e. async iterable): https://github.com/alanshaw/streamsearch-web - also types!