How to use the picomatch.scan function in picomatch

To help you get started, we’ve selected a few picomatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jonschlinkert / matched / lib / utils.js View on Github external
exports.sift = (patterns, options = {}) => {
  let results = { includes: [], excludes: [], globs: 0 };
  let index = 0;

  for (let pattern of [].concat(patterns || [])) {
    if (typeof pattern !== 'string') return null;
    let res = picomatch.scan(pattern);
    res.pattern = path.posix.join(res.base, res.glob);
    res.index = index++;

    if (res.isGlob) results.globs++;
    if (options.relative) {
      res.pattern = exports.toRelative(res.pattern, options);
      delete options.cwd;
    }

    if (res.negated) {
      results.excludes.push(res);
    } else {
      results.includes.push(res);
    }
  }
  return results;

picomatch

Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.

MIT
Latest version published 7 months ago

Package Health Score

88 / 100
Full package analysis