index.js
function(fs, globs, opt) {
    if (!opt) opt = {};
    if (typeof opt.cwd !== 'string') opt.cwd = fs.resolve('.');
    if (typeof opt.dot !== 'boolean') opt.dot = false;
    if (typeof opt.silent !== 'boolean') opt.silent = true;
    if (typeof opt.nonull !== 'boolean') opt.nonull = false;
    if (typeof opt.cwdbase !== 'boolean') opt.cwdbase = false;
    if (opt.cwdbase) opt.base = opt.cwd;

    // only one glob no need to aggregate
    if (!Array.isArray(globs)) globs = [globs];

    var positives = [];
    var negatives = [];

    var ourOpt = extend({}, opt);
    delete ourOpt.root;
    
    globs.forEach(function(glob, index) {
      if (typeof glob !== 'string' && !(glob instanceof RegExp)) {
        throw new Error('Invalid glob at index ' + index);
      }

      var globArray = isNegative(glob) ? negatives : positives;

      // create Minimatch instances for negative glob patterns
      if (globArray === negatives && typeof glob === 'string') {
        var ourGlob = resolveGlob(glob, opt);
        glob = new Minimatch(ourGlob, ourOpt);
      }

      globArray.push({
        index: index,
        glob: glob
      });
    });

    if (positives.length === 0) throw new Error('Missing positive glob');

    // only one positive glob no need to aggregate
    if (positives.length === 1) return streamFromPositive(positives[0]);

    // create all individual streams
    var streams = positives.map(streamFromPositive);

    // then just pipe them to a single unique stream and return it
    var aggregate = new Combine(streams);
    var uniqueStream = unique('path');
    var returnStream = aggregate.pipe(uniqueStream);

    aggregate.on('error', function (err) {
      returnStream.emit('error', err);
    });

    return returnStream;

    function streamFromPositive(positive) {
      var negativeGlobs = negatives.filter(indexGreaterThan(positive.index)).map(toGlob);
      return gs.createStream(fs, positive.glob, negativeGlobs, opt);
    }
  }
function(fs, globs, opt) {
    if (!opt) opt = {};
    if (typeof opt.cwd !== 'string') opt.cwd = fs.resolve('.');
    if (typeof opt.dot !== 'boolean') opt.dot = false;
    if (typeof opt.silent !== 'boolean') opt.silent = true;
    if (typeof opt.nonull !== 'boolean') opt.nonull = false;
    if (typeof opt.cwdbase !== 'boolean') opt.cwdbase = false;
    if (opt.cwdbase) opt.base = opt.cwd;

    // only one glob no need to aggregate
    if (!Array.isArray(globs)) globs = [globs];

    var positives = [];
    var negatives = [];

    var ourOpt = extend({}, opt);
    delete ourOpt.root;
    
    globs.forEach(function(glob, index) {
      if (typeof glob !== 'string' && !(glob instanceof RegExp)) {
        throw new Error('Invalid glob at index ' + index);
      }

      var globArray = isNegative(glob) ? negatives : positives;

      // create Minimatch instances for negative glob patterns
      if (globArray === negatives && typeof glob === 'string') {
        var ourGlob = resolveGlob(glob, opt);
        glob = new Minimatch(ourGlob, ourOpt);
      }

      globArray.push({
        index: index,
        glob: glob
      });
    });

    if (positives.length === 0) throw new Error('Missing positive glob');

    // only one positive glob no need to aggregate
    if (positives.length === 1) return streamFromPositive(positives[0]);

    // create all individual streams
    var streams = positives.map(streamFromPositive);

    // then just pipe them to a single unique stream and return it
    var aggregate = new Combine(streams);
    var uniqueStream = unique('path');
    var returnStream = aggregate.pipe(uniqueStream);

    aggregate.on('error', function (err) {
      returnStream.emit('error', err);
    });

    return returnStream;

    function streamFromPositive(positive) {
      var negativeGlobs = negatives.filter(indexGreaterThan(positive.index)).map(toGlob);
      return gs.createStream(fs, positive.glob, negativeGlobs, opt);
    }
  }
function ( fs , globs , opt ) { if ( ! opt ) opt = { } ; if ( typeof opt . cwd !== 'string' ) opt . cwd = fs . resolve ( '.' ) ; if ( typeof opt . dot !== 'boolean' ) opt . dot = false ; if ( typeof opt . silent !== 'boolean' ) opt . silent = true ; if ( typeof opt . nonull !== 'boolean' ) opt . nonull = false ; if ( typeof opt . cwdbase !== 'boolean' ) opt . cwdbase = false ; if ( opt . cwdbase ) opt . base = opt . cwd ; // only one glob no need to aggregate if ( ! Array . isArray ( globs ) ) globs = [ globs ] ; var positives = [ ] ; var negatives = [ ] ; var ourOpt = extend ( { } , opt ) ; delete ourOpt . root ; globs . forEach ( function ( glob , index ) { if ( typeof glob !== 'string' && ! ( glob instanceof RegExp ) ) { throw new Error ( 'Invalid glob at index ' + index ) ; } var globArray = isNegative ( glob ) ? negatives : positives ; // create Minimatch instances for negative glob patterns if ( globArray === negatives && typeof glob === 'string' ) { var ourGlob = resolveGlob ( glob , opt ) ; glob = new Minimatch ( ourGlob , ourOpt ) ; } globArray . push ( { index : index , glob : glob } ) ; } ) ; if ( positives . length === 0 ) throw new Error ( 'Missing positive glob' ) ; // only one positive glob no need to aggregate if ( positives . length === 1 ) return streamFromPositive ( positives [ 0 ] ) ; // create all individual streams var streams = positives . map ( streamFromPositive ) ; // then just pipe them to a single unique stream and return it var aggregate = new Combine ( streams ) ; var uniqueStream = unique ( 'path' ) ; var returnStream = aggregate . pipe ( uniqueStream ) ; aggregate . on ( 'error' , function ( err ) { returnStream . emit ( 'error' , err ) ; } ) ; return returnStream ; function streamFromPositive ( positive ) { var negativeGlobs = negatives . filter ( indexGreaterThan ( positive . index ) ) . map ( toGlob ) ; return gs . createStream ( fs , positive . glob , negativeGlobs , opt ) ; } }
creates a stream for multiple globs or filters
creates a stream for multiple globs or filters