Socket
Socket
Sign inDemoInstall

fast-glob

Package Overview
Dependencies
17
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.1 to 3.2.0-beta

out/providers/matchers/matcher.d.ts

24

out/index.js

@@ -8,11 +8,7 @@ "use strict";

const utils = require("./utils");
function FastGlob(source, options) {
try {
assertPatternsInput(source);
}
catch (error) {
return Promise.reject(error);
}
async function FastGlob(source, options) {
assertPatternsInput(source);
const works = getWorks(source, async_1.default, options);
return Promise.all(works).then(utils.array.flatten);
const result = await Promise.all(works);
return utils.array.flatten(result);
}

@@ -65,11 +61,9 @@ // https://github.com/typescript-eslint/typescript-eslint/issues/60

}
function assertPatternsInput(source) {
if ([].concat(source).every(isString)) {
return;
function assertPatternsInput(input) {
const source = [].concat(input);
const isValidSource = source.every((item) => utils.string.isString(item) && !utils.string.isEmpty(item));
if (!isValidSource) {
throw new TypeError('Patterns must be a string (non empty) or an array of strings');
}
throw new TypeError('Patterns must be a string or an array of strings');
}
function isString(source) {
return typeof source === 'string';
}
module.exports = FastGlob;

@@ -0,3 +1,3 @@

import { MicromatchOptions, EntryFilterFunction, Pattern } from '../../types';
import Settings from '../../settings';
import { EntryFilterFunction, MicromatchOptions, Pattern } from '../../types';
export default class DeepFilter {

@@ -8,10 +8,10 @@ private readonly _settings;

getFilter(basePath: string, positive: Pattern[], negative: Pattern[]): EntryFilterFunction;
private _getMaxPatternDepth;
private _getMatcher;
private _getNegativePatternsRe;
private _filter;
private _getEntryDepth;
private _isSkippedByDeep;
private _isSkippedByMaxPatternDepth;
private _isSkippedSymbolicLink;
private _getEntryLevel;
private _isSkippedByPositivePatterns;
private _isSkippedByNegativePatterns;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils = require("../../utils");
const partial_1 = require("../matchers/partial");
class DeepFilter {

@@ -10,9 +11,8 @@ constructor(_settings, _micromatchOptions) {

getFilter(basePath, positive, negative) {
const maxPatternDepth = this._getMaxPatternDepth(positive);
const matcher = this._getMatcher(positive);
const negativeRe = this._getNegativePatternsRe(negative);
return (entry) => this._filter(basePath, entry, negativeRe, maxPatternDepth);
return (entry) => this._filter(basePath, entry, matcher, negativeRe);
}
_getMaxPatternDepth(patterns) {
const globstar = patterns.some(utils.pattern.hasGlobStar);
return globstar ? Infinity : utils.pattern.getMaxNaivePatternsDepth(patterns);
_getMatcher(patterns) {
return new partial_1.default(patterns, this._micromatchOptions);
}

@@ -23,11 +23,11 @@ _getNegativePatternsRe(patterns) {

}
_filter(basePath, entry, negativeRe, maxPatternDepth) {
const depth = this._getEntryDepth(basePath, entry.path);
_filter(basePath, entry, matcher, negativeRe) {
const depth = this._getEntryLevel(basePath, entry.path);
if (this._isSkippedByDeep(depth)) {
return false;
}
if (this._isSkippedByMaxPatternDepth(depth, maxPatternDepth)) {
if (this._isSkippedSymbolicLink(entry)) {
return false;
}
if (this._isSkippedSymbolicLink(entry)) {
if (this._isSkippedByPositivePatterns(entry, matcher)) {
return false;

@@ -37,16 +37,20 @@ }

}
_getEntryDepth(basePath, entryPath) {
const basePathDepth = basePath.split('/').length;
const entryPathDepth = entryPath.split('/').length;
return entryPathDepth - (basePath === '' ? 0 : basePathDepth);
}
_isSkippedByDeep(entryDepth) {
return entryDepth >= this._settings.deep;
}
_isSkippedByMaxPatternDepth(entryDepth, maxPatternDepth) {
return !this._settings.baseNameMatch && maxPatternDepth !== Infinity && entryDepth > maxPatternDepth;
}
_isSkippedSymbolicLink(entry) {
return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
}
_getEntryLevel(basePath, entryPath) {
const basePathDepth = basePath.split('/').length;
const entryPathDepth = entryPath.split('/').length;
return entryPathDepth - (basePath === '' ? 0 : basePathDepth);
}
_isSkippedByPositivePatterns(entry, matcher) {
const filepath = entry.path.replace(/^\.[/\\]/, '');
const parts = filepath.split('/');
const level = parts.length - 1;
const part = parts[level];
return !this._settings.baseNameMatch && !matcher.match(level, part);
}
_isSkippedByNegativePatterns(entry, negativeRe) {

@@ -53,0 +57,0 @@ return !utils.pattern.matchAny(entry.path, negativeRe);

export declare function flatten<T>(items: T[][]): T[];
export declare function splitWhen<T>(items: T[], predicate: (item: T) => boolean): T[][];

@@ -7,1 +7,16 @@ "use strict";

exports.flatten = flatten;
function splitWhen(items, predicate) {
const result = [[]];
let groupIndex = 0;
for (const item of items) {
if (predicate(item)) {
groupIndex++;
result[groupIndex] = [];
}
else {
result[groupIndex].push(item);
}
}
return result;
}
exports.splitWhen = splitWhen;

@@ -7,2 +7,3 @@ import * as array from './array';

import * as stream from './stream';
export { array, errno, fs, path, pattern, stream };
import * as string from './string';
export { array, errno, fs, path, pattern, stream, string };

@@ -15,1 +15,3 @@ "use strict";

exports.stream = stream;
const string = require("./string");
exports.string = string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([*?|(){}[\]]|^!|[@+!](?=\())/g;
const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
/**

@@ -6,0 +6,0 @@ * Designed to work only with simple paths: `dir\\file`.

@@ -21,2 +21,5 @@ import { MicromatchOptions, Pattern, PatternRe } from '../types';

export declare function getMaxNaivePatternsDepth(patterns: Pattern[]): number;
export declare function expandPatternsWithBraceExpansion(patterns: Pattern[]): Pattern[];
export declare function expandBraceExpansion(pattern: Pattern): Pattern[];
export declare function getPatternParts(pattern: Pattern, options: MicromatchOptions): Pattern[];
export declare function makeRe(pattern: Pattern, options: MicromatchOptions): PatternRe;

@@ -23,0 +26,0 @@ export declare function convertPatternsToRe(patterns: Pattern[], options: MicromatchOptions): PatternRe[];

@@ -10,4 +10,4 @@ "use strict";

const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[.*]/;
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^@!*?+])\(.*\|.*\)/;
const GLOB_EXTENSION_SYMBOLS_RE = /[@!*?+]\(.*\)/;
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;

@@ -101,2 +101,24 @@ function isStaticPattern(pattern, options = {}) {

exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth;
function expandPatternsWithBraceExpansion(patterns) {
return patterns.reduce((collection, pattern) => {
return collection.concat(expandBraceExpansion(pattern));
}, []);
}
exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
function expandBraceExpansion(pattern) {
return micromatch.braces(pattern, {
expand: true,
nodupes: true
});
}
exports.expandBraceExpansion = expandBraceExpansion;
function getPatternParts(pattern, options) {
const info = micromatch.scan(pattern, Object.assign(Object.assign({}, options), { parts: true }));
// See micromatch/picomatch#58 for more details
if (info.parts.length === 0) {
return [pattern];
}
return info.parts;
}
exports.getPatternParts = getPatternParts;
function makeRe(pattern, options) {

@@ -111,5 +133,5 @@ return micromatch.makeRe(pattern, options);

function matchAny(entry, patternsRe) {
const filepath = entry.replace(/^\.[\\/]/, '');
const filepath = entry.replace(/^\.[/\\]/, '');
return patternsRe.some((patternRe) => patternRe.test(filepath));
}
exports.matchAny = matchAny;
{
"name": "fast-glob",
"version": "3.1.1",
"version": "3.2.0-beta",
"description": "It's a very fast and efficient glob library for Node.js",

@@ -29,3 +29,3 @@ "license": "MIT",

"@types/merge2": "^1.1.4",
"@types/micromatch": "^3.1.0",
"@types/micromatch": "^4.0.0",
"@types/minimist": "^1.2.0",

@@ -39,3 +39,3 @@ "@types/mocha": "^5.2.7",

"eslint": "^6.5.1",
"eslint-config-mrmlnc": "^1.0.1",
"eslint-config-mrmlnc": "^1.1.0",
"execa": "^2.0.4",

@@ -70,12 +70,18 @@ "fast-glob": "^3.0.4",

"bench": "npm run bench-async && npm run bench-stream && npm run bench-sync",
"bench-async": "npm run bench-async-flatten && npm run bench-async-deep",
"bench-stream": "npm run bench-stream-flatten && npm run bench-stream-deep",
"bench-sync": "npm run bench-sync-flatten && npm run bench-sync-deep",
"bench-async": "npm run bench-async-flatten && npm run bench-async-deep && npm run bench-async-partial-flatten && npm run bench-async-partial-deep",
"bench-stream": "npm run bench-stream-flatten && npm run bench-stream-deep && npm run bench-stream-partial-flatten && npm run bench-stream-partial-deep",
"bench-sync": "npm run bench-sync-flatten && npm run bench-sync-deep && npm run bench-sync-partial-flatten && npm run bench-sync-partial-deep",
"bench-async-flatten": "node ./out/benchmark --mode async --pattern \"*\"",
"bench-async-deep": "node ./out/benchmark --mode async --pattern \"**\"",
"bench-async-partial-flatten": "node ./out/benchmark --mode async --pattern \"{fixtures,out}/{first,second}/*\"",
"bench-async-partial-deep": "node ./out/benchmark --mode async --pattern \"{fixtures,out}/**\"",
"bench-stream-flatten": "node ./out/benchmark --mode stream --pattern \"*\"",
"bench-stream-deep": "node ./out/benchmark --mode stream --pattern \"**\"",
"bench-stream-partial-flatten": "node ./out/benchmark --mode stream --pattern \"{fixtures,out}/{first,second}/*\"",
"bench-stream-partial-deep": "node ./out/benchmark --mode stream --pattern \"{fixtures,out}/**\"",
"bench-sync-flatten": "node ./out/benchmark --mode sync --pattern \"*\"",
"bench-sync-deep": "node ./out/benchmark --mode sync --pattern \"**\""
"bench-sync-deep": "node ./out/benchmark --mode sync --pattern \"**\"",
"bench-sync-partial-flatten": "node ./out/benchmark --mode sync --pattern \"{fixtures,out}/{first,second}/*\"",
"bench-sync-partial-deep": "node ./out/benchmark --mode sync --pattern \"{fixtures,out}/**\""
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc