MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

lib/internal/fs/glob.js:340–381  ·  view source on GitHub ↗
(pattern, options = kEmptyObject)

Source from the content-addressed store, hash-verified

338 #followSymlinks = false;
339 #isExcluded = () => false;
340 constructor(pattern, options = kEmptyObject) {
341 validateObject(options, 'options');
342 const { exclude, cwd, followSymlinks, withFileTypes } = options;
343 this.#root = toPathIfFileURL(cwd) ?? '.';
344 if (followSymlinks != null) {
345 validateBoolean(followSymlinks, 'options.followSymlinks');
346 this.#followSymlinks = followSymlinks;
347 }
348 this.#withFileTypes = !!withFileTypes;
349 if (exclude != null) {
350 validateStringArrayOrFunction(exclude, 'options.exclude');
351 if (ArrayIsArray(exclude)) {
352 assert(typeof this.#root === 'string');
353 // Convert the path part of exclude patterns to absolute paths for
354 // consistent comparison before instantiating matchers.
355 const matchers = exclude
356 .map((pattern) => resolve(this.#root, pattern))
357 .map((pattern) => createMatcher(pattern));
358 this.#isExcluded = (value) =>
359 matchers.some((matcher) => matcher.match(value));
360 this.#results.setup(this.#root, this.#isExcluded);
361 } else {
362 this.#exclude = exclude;
363 }
364 }
365 let patterns;
366 if (typeof pattern === 'object') {
367 validateStringArray(pattern, 'patterns');
368 patterns = pattern;
369 } else {
370 validateString(pattern, 'patterns');
371 patterns = [pattern];
372 }
373 this.matchers = ArrayPrototypeMap(patterns, (pattern) => createMatcher(pattern));
374 this.#patterns = ArrayPrototypeFlatMap(this.matchers, (matcher) => ArrayPrototypeMap(matcher.set,
375 (pattern, i) => new Pattern(
376 pattern,
377 matcher.globParts[i],
378 new SafeSet().add(0),
379 new SafeSet(),
380 )));
381 }
382
383 globSync() {
384 ArrayPrototypePush(this.#queue, { __proto__: null, path: '.', patterns: this.#patterns });

Callers

nothing calls this directly

Calls 9

toPathIfFileURLFunction · 0.85
createMatcherFunction · 0.85
someMethod · 0.80
mapMethod · 0.65
matchMethod · 0.65
addMethod · 0.65
assertFunction · 0.50
resolveFunction · 0.50
setupMethod · 0.45

Tested by

no test coverage detected