source: trip-planner-front/node_modules/fast-glob/out/providers/matchers/matcher.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const utils = require("../../utils");
4class Matcher {
5 constructor(_patterns, _settings, _micromatchOptions) {
6 this._patterns = _patterns;
7 this._settings = _settings;
8 this._micromatchOptions = _micromatchOptions;
9 this._storage = [];
10 this._fillStorage();
11 }
12 _fillStorage() {
13 /**
14 * The original pattern may include `{,*,**,a/*}`, which will lead to problems with matching (unresolved level).
15 * So, before expand patterns with brace expansion into separated patterns.
16 */
17 const patterns = utils.pattern.expandPatternsWithBraceExpansion(this._patterns);
18 for (const pattern of patterns) {
19 const segments = this._getPatternSegments(pattern);
20 const sections = this._splitSegmentsIntoSections(segments);
21 this._storage.push({
22 complete: sections.length <= 1,
23 pattern,
24 segments,
25 sections
26 });
27 }
28 }
29 _getPatternSegments(pattern) {
30 const parts = utils.pattern.getPatternParts(pattern, this._micromatchOptions);
31 return parts.map((part) => {
32 const dynamic = utils.pattern.isDynamicPattern(part, this._settings);
33 if (!dynamic) {
34 return {
35 dynamic: false,
36 pattern: part
37 };
38 }
39 return {
40 dynamic: true,
41 pattern: part,
42 patternRe: utils.pattern.makeRe(part, this._micromatchOptions)
43 };
44 });
45 }
46 _splitSegmentsIntoSections(segments) {
47 return utils.array.splitWhen(segments, (segment) => segment.dynamic && utils.pattern.hasGlobStar(segment.pattern));
48 }
49}
50exports.default = Matcher;
Note: See TracBrowser for help on using the repository browser.