• Jump To … +
    all.js any.js anything.js array.js filter.js find.js index.js map.js pull.js range.js reduce.js reject.js s-pipe.js split.js
  • filter.js

  • ¶
    var PullStream = require('./pull');
  • ¶

    The FilterStream class will simply filter chunks that match a predicate

    var FilterStream = PullStream.extend({
      constructor: function FilterStream(source, cb) {
        PullStream.call(this, source);
        this._cb = cb;
      },
    
      _process: function(chunk) {
        if (this._cb(chunk)) this._forward(chunk);
      }
    });
    
    
    module.exports = function filter(cb) {
      return new FilterStream(this, cb);
    };