npmtest-gulp-tap (v0.0.1)

Code coverage report for node-npmtest-gulp-tap/gulp-tap/lib/tap.js

Statements: 14.71% (5 / 34)      Branches: 0% (0 / 8)      Functions: 0% (0 / 9)      Lines: 14.71% (5 / 34)      Ignored: none     

All files » node-npmtest-gulp-tap/gulp-tap/lib/ » tap.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77  1   1   1   1               1                                                                                                                          
// Generated by CoffeeScript 1.12.4
var DEBUG, baseStream, through;
 
baseStream = require('stream');
 
through = require('through2');
 
DEBUG = process.env.NODE_ENV === 'development';
 
 
/*
 * Taps into the pipeline and allows user to easily route data through
 * another stream or change content.
 */
 
module.exports = function(lambda) {
  var modifyFile, utils;
  utils = function(tapStream, file) {
    return {
 
      /*
       * Routes through another stream. The filter must not be
       * created. This will create the filter as needed.
       *
       * @param filter {stream}
       * @param args {Array} Array containg arguments to apply to filter.
       *
       * @example
       *   t.through coffee, [{bare: true}]
       */
      through: function(filter, args) {
        var stream;
        if (DEBUG) {
          if (!Array.isArray(args)) {
            throw new Error("Args must be an array to `apply` to the filter");
          }
        }
        stream = filter.apply(null, args);
        stream.on("error", function(err) {
          return tapStream.emit("error", err);
        });
        stream.write(file);
        return stream;
      }
    };
  };
  modifyFile = function(file, enc, cb) {
    var inst, next, obj;
    inst = {
      file: file
    };
    obj = lambda(inst.file, utils(this, inst.file), inst);
    next = (function(_this) {
      return function() {
        _this.push(file);
        return cb();
      };
    })(this);
    if (obj instanceof baseStream && !obj._readableState.ended) {
      obj.on('end', next);
      return obj.on('data', function() {
        obj.removeListener('end', next);
        obj.removeListener('data', arguments.callee);
        return next();
      });
    } else {
      return next();
    }
  };
  return through.obj(modifyFile, function(cb) {
    return cb();
  });
};
 
//# sourceMappingURL=tap.js.map