Create a Promise that will resolve when a Stream's data
event passes a condition.
npm install stream-when --save
Pass a callback function that will checked on each data event.
var child = spawn("echo", ["hello"]);
child.stdout.setEncoding("utf8");
var promise = streamWhen(child.stdout, function(data){
return data.trim() === "hello";
});
promise.then(function(){
// All done
});
Pass a Regular Expression that will be used to test.
var child = spawn("echo", ["hello"]);
child.stdout.setEncoding("utf8");
var promise = streamWhen(child.stdout, /hello/);
promise.then(function(){
// All done!
});
Pass a string value which will be converted into a RegExp.
var child = spawn("echo", ["hello"]);
child.stdout.setEncoding("utf8");
var promise = streamWhen(child.stdout, "hello");
promise.then(function(){
// All done@
});
BSD 2 Clause