File: //usr/share/nodejs/fast-glob/out/tests/utils/pattern.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.info = exports.segment = void 0;
const utils = require("../../utils");
class PatternSegmentBuilder {
constructor() {
this._segment = {
dynamic: false,
pattern: ''
};
}
dynamic() {
this._segment.dynamic = true;
return this;
}
pattern(pattern) {
this._segment.pattern = pattern;
return this;
}
build(options = {}) {
if (!this._segment.dynamic) {
return this._segment;
}
return Object.assign(Object.assign({}, this._segment), { patternRe: utils.pattern.makeRe(this._segment.pattern, options) });
}
}
class PatternInfoBuilder {
constructor() {
this._section = {
complete: true,
pattern: '',
segments: [],
sections: []
};
}
section(...segments) {
this._section.sections.push(segments);
if (this._section.segments.length === 0) {
this._section.complete = true;
this._section.segments.push(...segments);
}
else {
this._section.complete = false;
const globstar = segment().dynamic().pattern('**').build();
this._section.segments.push(globstar, ...segments);
}
return this;
}
build() {
return Object.assign(Object.assign({}, this._section), { pattern: this._buildPattern() });
}
_buildPattern() {
return this._section.segments.map((segment) => segment.pattern).join('/');
}
}
function segment() {
return new PatternSegmentBuilder();
}
exports.segment = segment;
function info() {
return new PatternInfoBuilder();
}
exports.info = info;