Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;