id
int64 0
3.78k
| code
stringlengths 13
37.9k
| declarations
stringlengths 16
64.6k
|
---|---|---|
600 | function getFastGlobEntriesStream(pattern: Pattern, ignore?: Pattern, cwd?: string, options?: Options): Promise<string[]> {
const entries: string[] = [];
const stream = fg.stream(pattern, getFastGlobOptions(ignore, cwd, options));
return new Promise((resolve, reject) => {
stream.on('data', (entry: string) => entries.push(entry));
stream.once('error', reject);
stream.once('end', () => {
entries.sort((a, b) => a.localeCompare(b));
resolve(entries);
});
});
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
601 | function getFastGlobOptions(ignore?: Pattern, cwd?: string, options?: Options): Options {
return {
cwd: cwd === undefined ? process.cwd() : cwd,
ignore: ignore === undefined ? [] : [ignore],
onlyFiles: false,
...options
};
} | type Pattern = string; |
602 | function getFastGlobOptions(ignore?: Pattern, cwd?: string, options?: Options): Options {
return {
cwd: cwd === undefined ? process.cwd() : cwd,
ignore: ignore === undefined ? [] : [ignore],
onlyFiles: false,
...options
};
} | type Options = OptionsInternal; |
603 | function getFastGlobOptions(ignore?: Pattern, cwd?: string, options?: Options): Options {
return {
cwd: cwd === undefined ? process.cwd() : cwd,
ignore: ignore === undefined ? [] : [ignore],
onlyFiles: false,
...options
};
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
604 | function convertPatternGroupsToTasks(positive: PatternsGroup, negative: Pattern[], dynamic: boolean): Task[] {
return Object.keys(positive).map((base) => {
return convertPatternGroupToTask(base, positive[base], negative, dynamic);
});
} | type PatternsGroup = Record<string, Pattern[]>; |
605 | transform(entry: Entry): EntryItem | type Entry = fsWalk.Entry; |
606 | (entry: Entry) => EntryItem | type Entry = fsWalk.Entry; |
607 | (entry: Entry) => entries.push(entry) | type Entry = fsWalk.Entry; |
608 | constructor(options?: Options) {
super(new Settings(options));
} | type Options = OptionsInternal; |
609 | constructor(options?: Options) {
super(new Settings(options));
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
610 | function getReader(options?: Options): TestReader {
return new TestReader(options);
} | type Options = OptionsInternal; |
611 | function getReader(options?: Options): TestReader {
return new TestReader(options);
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
612 | (error: ErrnoException) => {
assert.strictEqual(error.code, 'EPERM');
done();
} | type ErrnoException = NodeJS.ErrnoException; |
613 | constructor(protected readonly _settings: Settings) { } | class Settings {
public readonly absolute: boolean = this._getValue(this._options.absolute, false);
public readonly baseNameMatch: boolean = this._getValue(this._options.baseNameMatch, false);
public readonly braceExpansion: boolean = this._getValue(this._options.braceExpansion, true);
public readonly caseSensitiveMatch: boolean = this._getValue(this._options.caseSensitiveMatch, true);
public readonly concurrency: number = this._getValue(this._options.concurrency, CPU_COUNT);
public readonly cwd: string = this._getValue(this._options.cwd, process.cwd());
public readonly deep: number = this._getValue(this._options.deep, Infinity);
public readonly dot: boolean = this._getValue(this._options.dot, false);
public readonly extglob: boolean = this._getValue(this._options.extglob, true);
public readonly followSymbolicLinks: boolean = this._getValue(this._options.followSymbolicLinks, true);
public readonly fs: FileSystemAdapter = this._getFileSystemMethods(this._options.fs);
public readonly globstar: boolean = this._getValue(this._options.globstar, true);
public readonly ignore: Pattern[] = this._getValue(this._options.ignore, [] as Pattern[]);
public readonly markDirectories: boolean = this._getValue(this._options.markDirectories, false);
public readonly objectMode: boolean = this._getValue(this._options.objectMode, false);
public readonly onlyDirectories: boolean = this._getValue(this._options.onlyDirectories, false);
public readonly onlyFiles: boolean = this._getValue(this._options.onlyFiles, true);
public readonly stats: boolean = this._getValue(this._options.stats, false);
public readonly suppressErrors: boolean = this._getValue(this._options.suppressErrors, false);
public readonly throwErrorOnBrokenSymbolicLink: boolean = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
public readonly unique: boolean = this._getValue(this._options.unique, true);
constructor(private readonly _options: Options = {}) {
if (this.onlyDirectories) {
this.onlyFiles = false;
}
if (this.stats) {
this.objectMode = true;
}
}
private _getValue<T>(option: T | undefined, value: T): T {
return option === undefined ? value : option;
}
private _getFileSystemMethods(methods: Partial<FileSystemAdapter> = {}): FileSystemAdapter {
return {
...DEFAULT_FILE_SYSTEM_ADAPTER,
...methods
};
}
} |
614 | protected _isFatalError(error: ErrnoException): boolean {
return !utils.errno.isEnoentCodeError(error) && !this._settings.suppressErrors;
} | type ErrnoException = NodeJS.ErrnoException; |
615 | (error: ErrnoException) => {
if (options.errorFilter(error)) {
return null;
}
throw error;
} | type ErrnoException = NodeJS.ErrnoException; |
616 | public getRootDirectory(task: Task): string {
return this._getRootDirectory(task);
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
617 | public getReaderOptions(task: Task): ReaderOptions {
return this._getReaderOptions(task);
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
618 | function getProvider(options?: Options): TestProvider {
const settings = new Settings(options);
return new TestProvider(settings);
} | type Options = OptionsInternal; |
619 | function getProvider(options?: Options): TestProvider {
const settings = new Settings(options);
return new TestProvider(settings);
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
620 | public read(task: Task): EntryItem[] {
const root = this._getRootDirectory(task);
const options = this._getReaderOptions(task);
const entries = this.api(root, task, options);
return entries.map(options.transform);
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
621 | public async read(task: Task): Promise<EntryItem[]> {
const root = this._getRootDirectory(task);
const options = this._getReaderOptions(task);
const entries = await this.api(root, task, options);
return entries.map((entry) => options.transform(entry));
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
622 | public abstract read(_task: Task): T | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
623 | protected _getRootDirectory(task: Task): string {
return path.resolve(this._settings.cwd, task.base);
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
624 | protected _getReaderOptions(task: Task): ReaderOptions {
const basePath = task.base === '.' ? '' : task.base;
return {
basePath,
pathSegmentSeparator: '/',
concurrency: this._settings.concurrency,
deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
errorFilter: this.errorFilter.getFilter(),
followSymbolicLinks: this._settings.followSymbolicLinks,
fs: this._settings.fs,
stats: this._settings.stats,
throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink,
transform: this.entryTransformer.getTransformer()
};
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
625 | function getProvider(options?: Options): TestProvider {
return new TestProvider(options);
} | type Options = OptionsInternal; |
626 | function getProvider(options?: Options): TestProvider {
return new TestProvider(options);
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
627 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
const reader = new PassThrough({ objectMode: true });
provider.reader.dynamic.returns(reader);
provider.reader.static.returns(reader);
reader.push(entry);
reader.push(null);
return new Promise((resolve, reject) => {
const items: EntryItem[] = [];
const api = provider.read(task);
api.on('data', (item: EntryItem) => items.push(item));
api.once('error', reject);
api.once('end', () => resolve(items));
});
} | type Entry = fsWalk.Entry; |
628 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
const reader = new PassThrough({ objectMode: true });
provider.reader.dynamic.returns(reader);
provider.reader.static.returns(reader);
reader.push(entry);
reader.push(null);
return new Promise((resolve, reject) => {
const items: EntryItem[] = [];
const api = provider.read(task);
api.on('data', (item: EntryItem) => items.push(item));
api.once('error', reject);
api.once('end', () => resolve(items));
});
} | class TestProvider extends Provider<Array<{}>> {
public read(): Array<{}> {
return [];
}
public getRootDirectory(task: Task): string {
return this._getRootDirectory(task);
}
public getReaderOptions(task: Task): ReaderOptions {
return this._getReaderOptions(task);
}
public getMicromatchOptions(): MicromatchOptions {
return this._getMicromatchOptions();
}
} |
629 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
const reader = new PassThrough({ objectMode: true });
provider.reader.dynamic.returns(reader);
provider.reader.static.returns(reader);
reader.push(entry);
reader.push(null);
return new Promise((resolve, reject) => {
const items: EntryItem[] = [];
const api = provider.read(task);
api.on('data', (item: EntryItem) => items.push(item));
api.once('error', reject);
api.once('end', () => resolve(items));
});
} | class TestProvider extends ProviderStream {
protected _reader: ReaderStream = sinon.createStubInstance(ReaderStream) as unknown as ReaderStream;
constructor(options?: Options) {
super(new Settings(options));
}
public get reader(): sinon.SinonStubbedInstance<ReaderStream> {
return this._reader as unknown as sinon.SinonStubbedInstance<ReaderStream>;
}
} |
630 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
const reader = new PassThrough({ objectMode: true });
provider.reader.dynamic.returns(reader);
provider.reader.static.returns(reader);
reader.push(entry);
reader.push(null);
return new Promise((resolve, reject) => {
const items: EntryItem[] = [];
const api = provider.read(task);
api.on('data', (item: EntryItem) => items.push(item));
api.once('error', reject);
api.once('end', () => resolve(items));
});
} | class TestProvider extends ProviderAsync {
protected _reader: ReaderAsync = sinon.createStubInstance(ReaderAsync) as unknown as ReaderAsync;
constructor(options?: Options) {
super(new Settings(options));
}
public get reader(): sinon.SinonStubbedInstance<ReaderStream> {
return this._reader as unknown as sinon.SinonStubbedInstance<ReaderStream>;
}
} |
631 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
const reader = new PassThrough({ objectMode: true });
provider.reader.dynamic.returns(reader);
provider.reader.static.returns(reader);
reader.push(entry);
reader.push(null);
return new Promise((resolve, reject) => {
const items: EntryItem[] = [];
const api = provider.read(task);
api.on('data', (item: EntryItem) => items.push(item));
api.once('error', reject);
api.once('end', () => resolve(items));
});
} | class TestProvider extends ProviderSync {
protected _reader: ReaderSync = sinon.createStubInstance(ReaderSync) as unknown as ReaderSync;
constructor(options?: Options) {
super(new Settings(options));
}
public get reader(): sinon.SinonStubbedInstance<ReaderSync> {
return this._reader as unknown as sinon.SinonStubbedInstance<ReaderSync>;
}
} |
632 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
const reader = new PassThrough({ objectMode: true });
provider.reader.dynamic.returns(reader);
provider.reader.static.returns(reader);
reader.push(entry);
reader.push(null);
return new Promise((resolve, reject) => {
const items: EntryItem[] = [];
const api = provider.read(task);
api.on('data', (item: EntryItem) => items.push(item));
api.once('error', reject);
api.once('end', () => resolve(items));
});
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
633 | (item: EntryItem) => items.push(item) | type EntryItem = string | Entry; |
634 | (error: ErrnoException) => {
assert.strictEqual(error.code, 'ENOENT');
done();
} | type ErrnoException = NodeJS.ErrnoException; |
635 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
provider.reader.dynamic.resolves([entry]);
provider.reader.static.resolves([entry]);
return provider.read(task);
} | type Entry = fsWalk.Entry; |
636 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
provider.reader.dynamic.resolves([entry]);
provider.reader.static.resolves([entry]);
return provider.read(task);
} | class TestProvider extends Provider<Array<{}>> {
public read(): Array<{}> {
return [];
}
public getRootDirectory(task: Task): string {
return this._getRootDirectory(task);
}
public getReaderOptions(task: Task): ReaderOptions {
return this._getReaderOptions(task);
}
public getMicromatchOptions(): MicromatchOptions {
return this._getMicromatchOptions();
}
} |
637 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
provider.reader.dynamic.resolves([entry]);
provider.reader.static.resolves([entry]);
return provider.read(task);
} | class TestProvider extends ProviderStream {
protected _reader: ReaderStream = sinon.createStubInstance(ReaderStream) as unknown as ReaderStream;
constructor(options?: Options) {
super(new Settings(options));
}
public get reader(): sinon.SinonStubbedInstance<ReaderStream> {
return this._reader as unknown as sinon.SinonStubbedInstance<ReaderStream>;
}
} |
638 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
provider.reader.dynamic.resolves([entry]);
provider.reader.static.resolves([entry]);
return provider.read(task);
} | class TestProvider extends ProviderAsync {
protected _reader: ReaderAsync = sinon.createStubInstance(ReaderAsync) as unknown as ReaderAsync;
constructor(options?: Options) {
super(new Settings(options));
}
public get reader(): sinon.SinonStubbedInstance<ReaderStream> {
return this._reader as unknown as sinon.SinonStubbedInstance<ReaderStream>;
}
} |
639 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
provider.reader.dynamic.resolves([entry]);
provider.reader.static.resolves([entry]);
return provider.read(task);
} | class TestProvider extends ProviderSync {
protected _reader: ReaderSync = sinon.createStubInstance(ReaderSync) as unknown as ReaderSync;
constructor(options?: Options) {
super(new Settings(options));
}
public get reader(): sinon.SinonStubbedInstance<ReaderSync> {
return this._reader as unknown as sinon.SinonStubbedInstance<ReaderSync>;
}
} |
640 | function getEntries(provider: TestProvider, task: Task, entry: Entry): Promise<EntryItem[]> {
provider.reader.dynamic.resolves([entry]);
provider.reader.static.resolves([entry]);
return provider.read(task);
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
641 | public read(task: Task): Readable {
const root = this._getRootDirectory(task);
const options = this._getReaderOptions(task);
const source = this.api(root, task, options);
const destination = new Readable({ objectMode: true, read: () => { /* noop */ } });
source
.once('error', (error: ErrnoException) => destination.emit('error', error))
.on('data', (entry: Entry) => destination.emit('data', options.transform(entry)))
.once('end', () => destination.emit('end'));
destination
.once('close', () => source.destroy());
return destination;
} | type Task = {
base: string;
dynamic: boolean;
patterns: Pattern[];
positive: Pattern[];
negative: Pattern[];
}; |
642 | (error: ErrnoException) => destination.emit('error', error) | type ErrnoException = NodeJS.ErrnoException; |
643 | (entry: Entry) => destination.emit('data', options.transform(entry)) | type Entry = fsWalk.Entry; |
644 | function getEntryTransformer(options?: Options): EntryTransformer {
return new EntryTransformer(new Settings(options));
} | type Options = OptionsInternal; |
645 | function getEntryTransformer(options?: Options): EntryTransformer {
return new EntryTransformer(new Settings(options));
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
646 | function getTransformer(options?: Options): EntryTransformerFunction {
return getEntryTransformer(options).getTransformer();
} | type Options = OptionsInternal; |
647 | function getTransformer(options?: Options): EntryTransformerFunction {
return getEntryTransformer(options).getTransformer();
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
648 | constructor(private readonly _settings: Settings) { } | class Settings {
public readonly absolute: boolean = this._getValue(this._options.absolute, false);
public readonly baseNameMatch: boolean = this._getValue(this._options.baseNameMatch, false);
public readonly braceExpansion: boolean = this._getValue(this._options.braceExpansion, true);
public readonly caseSensitiveMatch: boolean = this._getValue(this._options.caseSensitiveMatch, true);
public readonly concurrency: number = this._getValue(this._options.concurrency, CPU_COUNT);
public readonly cwd: string = this._getValue(this._options.cwd, process.cwd());
public readonly deep: number = this._getValue(this._options.deep, Infinity);
public readonly dot: boolean = this._getValue(this._options.dot, false);
public readonly extglob: boolean = this._getValue(this._options.extglob, true);
public readonly followSymbolicLinks: boolean = this._getValue(this._options.followSymbolicLinks, true);
public readonly fs: FileSystemAdapter = this._getFileSystemMethods(this._options.fs);
public readonly globstar: boolean = this._getValue(this._options.globstar, true);
public readonly ignore: Pattern[] = this._getValue(this._options.ignore, [] as Pattern[]);
public readonly markDirectories: boolean = this._getValue(this._options.markDirectories, false);
public readonly objectMode: boolean = this._getValue(this._options.objectMode, false);
public readonly onlyDirectories: boolean = this._getValue(this._options.onlyDirectories, false);
public readonly onlyFiles: boolean = this._getValue(this._options.onlyFiles, true);
public readonly stats: boolean = this._getValue(this._options.stats, false);
public readonly suppressErrors: boolean = this._getValue(this._options.suppressErrors, false);
public readonly throwErrorOnBrokenSymbolicLink: boolean = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
public readonly unique: boolean = this._getValue(this._options.unique, true);
constructor(private readonly _options: Options = {}) {
if (this.onlyDirectories) {
this.onlyFiles = false;
}
if (this.stats) {
this.objectMode = true;
}
}
private _getValue<T>(option: T | undefined, value: T): T {
return option === undefined ? value : option;
}
private _getFileSystemMethods(methods: Partial<FileSystemAdapter> = {}): FileSystemAdapter {
return {
...DEFAULT_FILE_SYSTEM_ADAPTER,
...methods
};
}
} |
649 | private _transform(entry: Entry): EntryItem {
let filepath = entry.path;
if (this._settings.absolute) {
filepath = utils.path.makeAbsolute(this._settings.cwd, filepath);
filepath = utils.path.unixify(filepath);
}
if (this._settings.markDirectories && entry.dirent.isDirectory()) {
filepath += '/';
}
if (!this._settings.objectMode) {
return filepath;
}
return {
...entry,
path: filepath
};
} | type Entry = fsWalk.Entry; |
650 | constructor(private readonly _settings: Settings, private readonly _micromatchOptions: MicromatchOptions) { } | class Settings {
public readonly absolute: boolean = this._getValue(this._options.absolute, false);
public readonly baseNameMatch: boolean = this._getValue(this._options.baseNameMatch, false);
public readonly braceExpansion: boolean = this._getValue(this._options.braceExpansion, true);
public readonly caseSensitiveMatch: boolean = this._getValue(this._options.caseSensitiveMatch, true);
public readonly concurrency: number = this._getValue(this._options.concurrency, CPU_COUNT);
public readonly cwd: string = this._getValue(this._options.cwd, process.cwd());
public readonly deep: number = this._getValue(this._options.deep, Infinity);
public readonly dot: boolean = this._getValue(this._options.dot, false);
public readonly extglob: boolean = this._getValue(this._options.extglob, true);
public readonly followSymbolicLinks: boolean = this._getValue(this._options.followSymbolicLinks, true);
public readonly fs: FileSystemAdapter = this._getFileSystemMethods(this._options.fs);
public readonly globstar: boolean = this._getValue(this._options.globstar, true);
public readonly ignore: Pattern[] = this._getValue(this._options.ignore, [] as Pattern[]);
public readonly markDirectories: boolean = this._getValue(this._options.markDirectories, false);
public readonly objectMode: boolean = this._getValue(this._options.objectMode, false);
public readonly onlyDirectories: boolean = this._getValue(this._options.onlyDirectories, false);
public readonly onlyFiles: boolean = this._getValue(this._options.onlyFiles, true);
public readonly stats: boolean = this._getValue(this._options.stats, false);
public readonly suppressErrors: boolean = this._getValue(this._options.suppressErrors, false);
public readonly throwErrorOnBrokenSymbolicLink: boolean = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
public readonly unique: boolean = this._getValue(this._options.unique, true);
constructor(private readonly _options: Options = {}) {
if (this.onlyDirectories) {
this.onlyFiles = false;
}
if (this.stats) {
this.objectMode = true;
}
}
private _getValue<T>(option: T | undefined, value: T): T {
return option === undefined ? value : option;
}
private _getFileSystemMethods(methods: Partial<FileSystemAdapter> = {}): FileSystemAdapter {
return {
...DEFAULT_FILE_SYSTEM_ADAPTER,
...methods
};
}
} |
651 | constructor(private readonly _settings: Settings, private readonly _micromatchOptions: MicromatchOptions) { } | type MicromatchOptions = {
dot?: boolean;
matchBase?: boolean;
nobrace?: boolean;
nocase?: boolean;
noext?: boolean;
noglobstar?: boolean;
posix?: boolean;
strictSlashes?: boolean;
}; |
652 | private _isSkippedSymbolicLink(entry: Entry): boolean {
return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink();
} | type Entry = fsWalk.Entry; |
653 | function getEntryFilterInstance(options?: Options): EntryFilter {
const settings = new Settings(options);
return new EntryFilter(settings, {
dot: settings.dot
});
} | type Options = OptionsInternal; |
654 | function getEntryFilterInstance(options?: Options): EntryFilter {
const settings = new Settings(options);
return new EntryFilter(settings, {
dot: settings.dot
});
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
655 | function getFilter(options: FilterOptions): EntryFilterFunction {
const negative = options.negative ?? [];
return getEntryFilterInstance(options.options).getFilter(options.positive, negative);
} | type FilterOptions = {
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
656 | function getFilter(options: FilterOptions): EntryFilterFunction {
const negative = options.negative ?? [];
return getEntryFilterInstance(options.options).getFilter(options.positive, negative);
} | type FilterOptions = {
base?: string;
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
657 | function getResult(entry: Entry, options: FilterOptions): boolean {
const filter = getFilter(options);
return filter(entry);
} | type Entry = fsWalk.Entry; |
658 | function getResult(entry: Entry, options: FilterOptions): boolean {
const filter = getFilter(options);
return filter(entry);
} | type FilterOptions = {
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
659 | function getResult(entry: Entry, options: FilterOptions): boolean {
const filter = getFilter(options);
return filter(entry);
} | type FilterOptions = {
base?: string;
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
660 | function accept(entry: Entry, options: FilterOptions): void {
assert.strictEqual(getResult(entry, options), true);
} | type Entry = fsWalk.Entry; |
661 | function accept(entry: Entry, options: FilterOptions): void {
assert.strictEqual(getResult(entry, options), true);
} | type FilterOptions = {
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
662 | function accept(entry: Entry, options: FilterOptions): void {
assert.strictEqual(getResult(entry, options), true);
} | type FilterOptions = {
base?: string;
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
663 | function reject(entry: Entry, options: FilterOptions): void {
assert.strictEqual(getResult(entry, options), false);
} | type Entry = fsWalk.Entry; |
664 | function reject(entry: Entry, options: FilterOptions): void {
assert.strictEqual(getResult(entry, options), false);
} | type FilterOptions = {
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
665 | function reject(entry: Entry, options: FilterOptions): void {
assert.strictEqual(getResult(entry, options), false);
} | type FilterOptions = {
base?: string;
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
666 | constructor(private readonly _settings: Settings, private readonly _micromatchOptions: MicromatchOptions) {} | class Settings {
public readonly absolute: boolean = this._getValue(this._options.absolute, false);
public readonly baseNameMatch: boolean = this._getValue(this._options.baseNameMatch, false);
public readonly braceExpansion: boolean = this._getValue(this._options.braceExpansion, true);
public readonly caseSensitiveMatch: boolean = this._getValue(this._options.caseSensitiveMatch, true);
public readonly concurrency: number = this._getValue(this._options.concurrency, CPU_COUNT);
public readonly cwd: string = this._getValue(this._options.cwd, process.cwd());
public readonly deep: number = this._getValue(this._options.deep, Infinity);
public readonly dot: boolean = this._getValue(this._options.dot, false);
public readonly extglob: boolean = this._getValue(this._options.extglob, true);
public readonly followSymbolicLinks: boolean = this._getValue(this._options.followSymbolicLinks, true);
public readonly fs: FileSystemAdapter = this._getFileSystemMethods(this._options.fs);
public readonly globstar: boolean = this._getValue(this._options.globstar, true);
public readonly ignore: Pattern[] = this._getValue(this._options.ignore, [] as Pattern[]);
public readonly markDirectories: boolean = this._getValue(this._options.markDirectories, false);
public readonly objectMode: boolean = this._getValue(this._options.objectMode, false);
public readonly onlyDirectories: boolean = this._getValue(this._options.onlyDirectories, false);
public readonly onlyFiles: boolean = this._getValue(this._options.onlyFiles, true);
public readonly stats: boolean = this._getValue(this._options.stats, false);
public readonly suppressErrors: boolean = this._getValue(this._options.suppressErrors, false);
public readonly throwErrorOnBrokenSymbolicLink: boolean = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
public readonly unique: boolean = this._getValue(this._options.unique, true);
constructor(private readonly _options: Options = {}) {
if (this.onlyDirectories) {
this.onlyFiles = false;
}
if (this.stats) {
this.objectMode = true;
}
}
private _getValue<T>(option: T | undefined, value: T): T {
return option === undefined ? value : option;
}
private _getFileSystemMethods(methods: Partial<FileSystemAdapter> = {}): FileSystemAdapter {
return {
...DEFAULT_FILE_SYSTEM_ADAPTER,
...methods
};
}
} |
667 | constructor(private readonly _settings: Settings, private readonly _micromatchOptions: MicromatchOptions) {} | type MicromatchOptions = {
dot?: boolean;
matchBase?: boolean;
nobrace?: boolean;
nocase?: boolean;
noext?: boolean;
noglobstar?: boolean;
posix?: boolean;
strictSlashes?: boolean;
}; |
668 | private _filter(entry: Entry, positiveRe: PatternRe[], negativeRe: PatternRe[]): boolean {
if (this._settings.unique && this._isDuplicateEntry(entry)) {
return false;
}
if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
return false;
}
if (this._isSkippedByAbsoluteNegativePatterns(entry.path, negativeRe)) {
return false;
}
const filepath = this._settings.baseNameMatch ? entry.name : entry.path;
const isDirectory = entry.dirent.isDirectory();
const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(entry.path, negativeRe, isDirectory);
if (this._settings.unique && isMatched) {
this._createIndexRecord(entry);
}
return isMatched;
} | type Entry = fsWalk.Entry; |
669 | private _isDuplicateEntry(entry: Entry): boolean {
return this.index.has(entry.path);
} | type Entry = fsWalk.Entry; |
670 | private _createIndexRecord(entry: Entry): void {
this.index.set(entry.path, undefined);
} | type Entry = fsWalk.Entry; |
671 | private _onlyFileFilter(entry: Entry): boolean {
return this._settings.onlyFiles && !entry.dirent.isFile();
} | type Entry = fsWalk.Entry; |
672 | private _onlyDirectoryFilter(entry: Entry): boolean {
return this._settings.onlyDirectories && !entry.dirent.isDirectory();
} | type Entry = fsWalk.Entry; |
673 | private _isNonFatalError(error: ErrnoException): boolean {
return utils.errno.isEnoentCodeError(error) || this._settings.suppressErrors;
} | type ErrnoException = NodeJS.ErrnoException; |
674 | function getDeepFilterInstance(options?: Options): DeepFilter {
const settings = new Settings(options);
return new DeepFilter(settings, {
dot: settings.dot
});
} | type Options = OptionsInternal; |
675 | function getDeepFilterInstance(options?: Options): DeepFilter {
const settings = new Settings(options);
return new DeepFilter(settings, {
dot: settings.dot
});
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
676 | function getFilter(options: FilterOptions): EntryFilterFunction {
const base = options.base ?? '.';
const negative = options.negative ?? [];
return getDeepFilterInstance(options.options).getFilter(base, options.positive, negative);
} | type FilterOptions = {
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
677 | function getFilter(options: FilterOptions): EntryFilterFunction {
const base = options.base ?? '.';
const negative = options.negative ?? [];
return getDeepFilterInstance(options.options).getFilter(base, options.positive, negative);
} | type FilterOptions = {
base?: string;
positive: Pattern[];
negative?: Pattern[];
options?: Options;
}; |
678 | function getErrorFilterInstance(options?: Options): ErrorFilter {
const settings = new Settings(options);
return new ErrorFilter(settings);
} | type Options = OptionsInternal; |
679 | function getErrorFilterInstance(options?: Options): ErrorFilter {
const settings = new Settings(options);
return new ErrorFilter(settings);
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
680 | function getFilter(options?: Options): ErrorFilterFunction {
return getErrorFilterInstance(options).getFilter();
} | type Options = OptionsInternal; |
681 | function getFilter(options?: Options): ErrorFilterFunction {
return getErrorFilterInstance(options).getFilter();
} | type Options = {
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* If set to `true`, then patterns without slashes will be matched against
* the basename of the path if it contains slashes.
*
* @default false
*/
baseNameMatch?: boolean;
/**
* Enables Bash-like brace expansion.
*
* @default true
*/
braceExpansion?: boolean;
/**
* Enables a case-sensitive mode for matching files.
*
* @default true
*/
caseSensitiveMatch?: boolean;
/**
* Specifies the maximum number of concurrent requests from a reader to read
* directories.
*
* @default os.cpus().length
*/
concurrency?: number;
/**
* The current working directory in which to search.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Specifies the maximum depth of a read directory relative to the start
* directory.
*
* @default Infinity
*/
deep?: number;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Enables Bash-like `extglob` functionality.
*
* @default true
*/
extglob?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default true
*/
followSymbolicLinks?: boolean;
/**
* Custom implementation of methods for working with the file system.
*
* @default fs.*
*/
fs?: Partial<FileSystemAdapter>;
/**
* Enables recursively repeats a pattern containing `**`.
* If `false`, `**` behaves exactly like `*`.
*
* @default true
*/
globstar?: boolean;
/**
* An array of glob patterns to exclude matches.
* This is an alternative way to use negative patterns.
*
* @default []
*/
ignore?: Pattern[];
/**
* Mark the directory path with the final slash.
*
* @default false
*/
markDirectories?: boolean;
/**
* Returns objects (instead of strings) describing entries.
*
* @default false
*/
objectMode?: boolean;
/**
* Return only directories.
*
* @default false
*/
onlyDirectories?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
/**
* Enables an object mode (`objectMode`) with an additional `stats` field.
*
* @default false
*/
stats?: boolean;
/**
* By default this package suppress only `ENOENT` errors.
* Set to `true` to suppress any error.
*
* @default false
*/
suppressErrors?: boolean;
/**
* Throw an error when symbolic link is broken if `true` or safely
* return `lstat` call if `false`.
*
* @default false
*/
throwErrorOnBrokenSymbolicLink?: boolean;
/**
* Ensures that the returned entries are unique.
*
* @default true
*/
unique?: boolean;
}; |
682 | private _getPatternSegments(pattern: Pattern): PatternSegment[] {
const parts = utils.pattern.getPatternParts(pattern, this._micromatchOptions);
return parts.map((part) => {
const dynamic = utils.pattern.isDynamicPattern(part, this._settings);
if (!dynamic) {
return {
dynamic: false,
pattern: part
};
}
return {
dynamic: true,
pattern: part,
patternRe: utils.pattern.makeRe(part, this._micromatchOptions)
};
});
} | type Pattern = string; |
683 | function dayPeriodEnumToHours(dayPeriod: LocaleDayPeriod): number {
switch (dayPeriod) {
case 'morning':
return 4
case 'evening':
return 17
case 'pm':
case 'noon':
case 'afternoon':
return 12
case 'am':
case 'midnight':
case 'night':
default:
return 0
}
} | type LocaleDayPeriod =
| 'am'
| 'pm'
| 'midnight'
| 'noon'
| 'morning'
| 'afternoon'
| 'evening'
| 'night' |
684 | public validate<DateType extends Date>(
_utcDate: DateType,
_options?: ParserOptions
): boolean {
return true
} | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
685 | public abstract set<DateType extends Date>(
utcDate: DateType,
flags: ParseFlags,
options: ParserOptions
): DateType | [DateType, ParseFlags] | interface ParseFlags {
timestampIsSet?: boolean
era?: number
} |
686 | public abstract set<DateType extends Date>(
utcDate: DateType,
flags: ParseFlags,
options: ParserOptions
): DateType | [DateType, ParseFlags] | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
687 | constructor(
private value: Value,
private validateValue: <DateType extends Date>(
utcDate: DateType,
value: Value,
options: ParserOptions
) => boolean,
private setValue: <DateType extends Date>(
utcDate: DateType,
flags: ParseFlags,
value: Value,
options: ParserOptions
) => DateType | [DateType, ParseFlags],
public priority: number,
subPriority?: number
) {
super()
if (subPriority) {
this.subPriority = subPriority
}
} | interface ParseFlags {
timestampIsSet?: boolean
era?: number
} |
688 | constructor(
private value: Value,
private validateValue: <DateType extends Date>(
utcDate: DateType,
value: Value,
options: ParserOptions
) => boolean,
private setValue: <DateType extends Date>(
utcDate: DateType,
flags: ParseFlags,
value: Value,
options: ParserOptions
) => DateType | [DateType, ParseFlags],
public priority: number,
subPriority?: number
) {
super()
if (subPriority) {
this.subPriority = subPriority
}
} | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
689 | <DateType extends Date>(
utcDate: DateType,
value: Value,
options: ParserOptions
) => boolean | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
690 | <DateType extends Date>(
utcDate: DateType,
flags: ParseFlags,
value: Value,
options: ParserOptions
) => DateType | [DateType, ParseFlags] | interface ParseFlags {
timestampIsSet?: boolean
era?: number
} |
691 | <DateType extends Date>(
utcDate: DateType,
flags: ParseFlags,
value: Value,
options: ParserOptions
) => DateType | [DateType, ParseFlags] | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
692 | validate<DateType extends Date>(
date: DateType,
options: ParserOptions
): boolean {
return this.validateValue(date, this.value, options)
} | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
693 | set<DateType extends Date>(
date: DateType,
flags: ParseFlags,
options: ParserOptions
): DateType | [DateType, ParseFlags] {
return this.setValue(date, flags, this.value, options)
} | interface ParseFlags {
timestampIsSet?: boolean
era?: number
} |
694 | set<DateType extends Date>(
date: DateType,
flags: ParseFlags,
options: ParserOptions
): DateType | [DateType, ParseFlags] {
return this.setValue(date, flags, this.value, options)
} | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
695 | set<DateType extends Date>(date: DateType, flags: ParseFlags): DateType {
if (flags.timestampIsSet) return date
return constructFrom(date, transpose(date, Date))
} | interface ParseFlags {
timestampIsSet?: boolean
era?: number
} |
696 | protected validate<DateType extends Date>(
_utcDate: DateType,
_value: Value,
_options: ParserOptions
): boolean {
return true
} | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
697 | protected abstract set<DateType extends Date>(
date: DateType,
flags: ParseFlags,
value: Value,
options: ParserOptions
): DateType | [DateType, ParseFlags] | interface ParseFlags {
timestampIsSet?: boolean
era?: number
} |
698 | protected abstract set<DateType extends Date>(
date: DateType,
flags: ParseFlags,
value: Value,
options: ParserOptions
): DateType | [DateType, ParseFlags] | type ParserOptions = Required<
LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions
> |
699 | set<DateType extends Date>(
date: DateType,
flags: ParseFlags,
value: number
): DateType {
if (flags.timestampIsSet) return date
return constructFrom(
date,
date.getTime() - getTimezoneOffsetInMilliseconds(date) - value
)
} | interface ParseFlags {
timestampIsSet?: boolean
era?: number
} |
Subsets and Splits