function filter(patterns, opts) {
  if (!Array.isArray(patterns) && typeof patterns !== 'string') {
    throw new TypeError(msg('filter', 'patterns', 'a string or array'));
  }

  patterns = utils.arrayify(patterns);
  var len = patterns.length,
      i = 0;
  var patternMatchers = Array(len);

  while (i < len) {
    patternMatchers[i] = matcher(patterns[i++], opts);
  }

  return function (fp) {
    if (fp == null) return [];
    var len = patternMatchers.length,
        i = 0;
    var res = true;
    fp = utils.unixify(fp, opts);

    while (i < len) {
      var fn = patternMatchers[i++];

      if (!fn(fp)) {
        res = false;
        break;
      }
    }

    return res;
  };
}
Returns a function that takes a glob pattern or array of glob patterns
to be used with `Array#filter()`. (Internally this function generates
the matching function using the [matcher] method).

```js
var fn = mm.filter('[a-c]');
['a', 'b', 'c', 'd', 'e'].filter(fn);
//=> ['a', 'b', 'c']
```
@param  {String|Array} `patterns` Can be a glob or array of globs.
@param  {Options} `opts` Options to pass to the [matcher] method.
@return {Function} Filter function to be passed to `Array#filter()`.