New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add es.filter #63

Closed
mariusGundersen opened this Issue Jun 13, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@mariusGundersen

mariusGundersen commented Jun 13, 2014

There should be an equivalent of array.prototype.filter. I have used this simple wrapper around es.map:

es.filter = function(func){
  return es.map(function(data, next){
    func(data, function(result){
      if(result){
        next(null, data);
      }else{
        next();
      }
    })
  });
}

It can be used like this:

stream.pipe(es.filter(function(data, keep){
  keep(data.length > 0);
})).pipe(output);
@dominictarr

This comment has been minimized.

Owner

dominictarr commented Jun 13, 2014

I'm not adding any more features to this module, but this could be good as it's own module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment