Skip to content

Create a Promise for when a child process returns a particular text to stdout

Notifications You must be signed in to change notification settings

matthewp/stream-when

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

stream-when

Create a Promise that will resolve when a Stream's data event passes a condition.

Install

npm install stream-when --save

Use

Function

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
});

RegExp

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!
});

String

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@
});

License

BSD 2 Clause

About

Create a Promise for when a child process returns a particular text to stdout

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published