1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | var Group_1 = __importDefault(require("./Group"));
|
7 | var GroupBuilder = (function () {
|
8 | function GroupBuilder() {
|
9 | this.capturing = true;
|
10 | this.groupBuilders = [];
|
11 | }
|
12 | GroupBuilder.prototype.add = function (groupBuilder) {
|
13 | this.groupBuilders.push(groupBuilder);
|
14 | };
|
15 | GroupBuilder.prototype.build = function (match, nextGroupIndex) {
|
16 | var groupIndex = nextGroupIndex();
|
17 | var children = this.groupBuilders.map(function (gb) {
|
18 | return gb.build(match, nextGroupIndex);
|
19 | });
|
20 | return new Group_1.default(match[groupIndex] || null, match.index[groupIndex], match.index[groupIndex] + (match[groupIndex] || '').length, children);
|
21 | };
|
22 | GroupBuilder.prototype.setNonCapturing = function () {
|
23 | this.capturing = false;
|
24 | };
|
25 | Object.defineProperty(GroupBuilder.prototype, "children", {
|
26 | get: function () {
|
27 | return this.groupBuilders;
|
28 | },
|
29 | enumerable: true,
|
30 | configurable: true
|
31 | });
|
32 | GroupBuilder.prototype.moveChildrenTo = function (groupBuilder) {
|
33 | this.groupBuilders.forEach(function (child) { return groupBuilder.add(child); });
|
34 | };
|
35 | return GroupBuilder;
|
36 | }());
|
37 | exports.default = GroupBuilder;
|
38 |
|
\ | No newline at end of file |