index.js
function nanomatch(list, patterns, options) {
  patterns = utils.arrayify(patterns);
  list = utils.arrayify(list);

  const len = patterns.length;
  if (list.length === 0 || len === 0) {
    return [];
  }

  if (len === 1) {
    return nanomatch.match(list, patterns[0], options);
  }

  let negated = false;
  const omit = [];
  const keep = [];
  let idx = -1;

  while (++idx < len) {
    const pattern = patterns[idx];

    if (typeof pattern === 'string' && pattern.charCodeAt(0) === 33 /* ! */) {
      omit.push.apply(omit, nanomatch.match(list, pattern.slice(1), options));
      negated = true;
    } else {
      keep.push.apply(keep, nanomatch.match(list, pattern, options));
    }
  }

  // minimatch.match parity
  if (negated && keep.length === 0) {
    if (options && options.unixify === false) {
      keep = list.slice();
    } else {
      const unixify = utils.unixify(options);
      for (var i = 0; i < list.length; i++) {
        keep.push(unixify(list[i]));
      }
    }
  }

  const matches = utils.diff(keep, omit);
  if (!options || options.nodupes !== false) {
    return utils.unique(matches);
  }

  return matches;
}
function nanomatch(list, patterns, options) {
  patterns = utils.arrayify(patterns);
  list = utils.arrayify(list);

  const len = patterns.length;
  if (list.length === 0 || len === 0) {
    return [];
  }

  if (len === 1) {
    return nanomatch.match(list, patterns[0], options);
  }

  let negated = false;
  const omit = [];
  const keep = [];
  let idx = -1;

  while (++idx < len) {
    const pattern = patterns[idx];

    if (typeof pattern === 'string' && pattern.charCodeAt(0) === 33 /* ! */) {
      omit.push.apply(omit, nanomatch.match(list, pattern.slice(1), options));
      negated = true;
    } else {
      keep.push.apply(keep, nanomatch.match(list, pattern, options));
    }
  }

  // minimatch.match parity
  if (negated && keep.length === 0) {
    if (options && options.unixify === false) {
      keep = list.slice();
    } else {
      const unixify = utils.unixify(options);
      for (var i = 0; i < list.length; i++) {
        keep.push(unixify(list[i]));
      }
    }
  }

  const matches = utils.diff(keep, omit);
  if (!options || options.nodupes !== false) {
    return utils.unique(matches);
  }

  return matches;
}
function nanomatch ( list , patterns , options ) { patterns = utils . arrayify ( patterns ) ; list = utils . arrayify ( list ) ; const len = patterns . length ; if ( list . length === 0 || len === 0 ) { return [ ] ; } if ( len === 1 ) { return nanomatch . match ( list , patterns [ 0 ] , options ) ; } let negated = false ; const omit = [ ] ; const keep = [ ] ; let idx = - 1 ; while ( ++ idx < len ) { const pattern = patterns [ idx ] ; if ( typeof pattern === 'string' && pattern . charCodeAt ( 0 ) === 33 /* ! */ ) { omit . push . apply ( omit , nanomatch . match ( list , pattern . slice ( 1 ) , options ) ) ; negated = true ; } else { keep . push . apply ( keep , nanomatch . match ( list , pattern , options ) ) ; } } // minimatch.match parity if ( negated && keep . length === 0 ) { if ( options && options . unixify === false ) { keep = list . slice ( ) ; } else { const unixify = utils . unixify ( options ) ; for ( var i = 0 ; i < list . length ; i ++ ) { keep . push ( unixify ( list [ i ] ) ) ; } } } const matches = utils . diff ( keep , omit ) ; if ( ! options || options . nodupes !== false ) { return utils . unique ( matches ) ; } return matches ; }
The main function takes a list of strings and one or more
glob patterns to use for matching.

```js
const nm = require('nanomatch');
nm(list, patterns[, options]);

console.log(nm(['a.js', 'a.txt'], ['*.js']));
//=> [ 'a.js' ]
```
@param {Array} `list` A list of strings to match
@param {String|Array} `patterns` One or more glob patterns to use for matching.
@param {Object} `options` See available [options](#options) for changing how matches are performed
@return {Array} Returns an array of matches
@summary false
@api public
The main function takes a list of strings and one or more glob patterns to use for matching .