index.js
function middleware(fns) {
  return through.obj(function(file, enc, cb) {
    eachSeries(arrayify(fns), function(fn, next) {
      try {
        fn(file, next);
      } catch (err) {
        next(err);
      }
    }, function(err) {
      cb(err, file);
    });
  });
}
function middleware(fns) {
  return through.obj(function(file, enc, cb) {
    eachSeries(arrayify(fns), function(fn, next) {
      try {
        fn(file, next);
      } catch (err) {
        next(err);
      }
    }, function(err) {
      cb(err, file);
    });
  });
}
function middleware ( fns ) { return through . obj ( function ( file , enc , cb ) { eachSeries ( arrayify ( fns ) , function ( fn , next ) { try { fn ( file , next ) ; } catch ( err ) { next ( err ) ; } } , function ( err ) { cb ( err , file ) ; } ) ; } ) ; }
Run middleware in series.

```js
var middleware = require('gulp-middleware');

gulp.task('middleware', function() {
return gulp.src('*.js')
.pipe(middleware(fn('bar')))
.pipe(middleware([
fn('foo'),
fn('bar'),
fn('baz')
]))
});

function fn(name) {
return function(file, next) {
console.log(name);
next();
};
}
```
@param {Array|Function} `fns` Function or array of middleware functions
@api public
Run middleware in series .