• 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
  • map.js

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

    The MapStream class is a port of the 'map' function to streams: Each chunk emitted is passed through a callback that performs a transformation and then re-emitted to the next consumer.

    var MapStream = PullStream.extend({
      constructor: function MapStream(source, cb) {
        PullStream.call(this, source);
        this._cb = cb;
      },
  • ¶

    Each chunk pulled from the source is passed through the transform function.

      _process: function(chunk) {
        this._forward(this._cb(chunk));
      }
    });
    
    
    module.exports = function map(cb) {
      return new MapStream(this, cb);
    };