code: function appStream(app) {
    if (!hasHandler(app, 'onStream')) {
      app.handler('onStream');
    }
  
    return function(name, filterFn) {
      var stream = utils.through.obj();
      stream.setMaxListeners(0);
  
      if (typeof name === 'undefined') {
        process.nextTick(stream.end.bind(stream));
        return utils.src(stream);
      }
  
      var write = writeStream(stream);
      var collection = this[name];
      var views = collection && collection.views;
  
      if (!views && typeof name !== 'undefined') {
        filterFn = name;
        setImmediate(function() {
          Object.keys(this.views).forEach(function(key) {
            views = this.views[key];
            write(views, filterFn);
          }, this);
          stream.end();
        }.bind(this));
  
        return outStream(stream, this);
      }
  
      setImmediate(function() {
        write(views, filterFn);
        stream.end();
      });
  
      return outStream(stream, this);
    };
  }
docs: Push a view collection into a vinyl stream.
  
  ```js
  app.toStream('posts', function(file) {
  return file.path !== 'index.hbs';
  })
  ```
  @name app.toStream
  @param {String} `collection` Name of the collection to push into the stream.
  @param {Function} Optionally pass a filter function to use for filtering views.
  @return {Stream}
  @api public