feedsmith 3.0.0-beta.2 → 3.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/feeds/atom/parse/config.cjs +1 -2
- package/dist/feeds/atom/parse/config.js +1 -2
- package/dist/feeds/rdf/parse/config.cjs +1 -2
- package/dist/feeds/rdf/parse/config.js +1 -2
- package/dist/feeds/rss/parse/config.cjs +1 -2
- package/dist/feeds/rss/parse/config.js +1 -2
- package/dist/opml/parse/config.cjs +1 -2
- package/dist/opml/parse/config.js +1 -2
- package/package.json +3 -3
- package/dist/node_modules/path-expression-matcher/src/Expression.cjs +0 -153
- package/dist/node_modules/path-expression-matcher/src/Expression.js +0 -153
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_config = require("../../../common/config.cjs");
|
|
2
2
|
const require_utils = require("../../../common/utils.cjs");
|
|
3
|
-
const require_Expression = require("../../../node_modules/path-expression-matcher/src/Expression.cjs");
|
|
4
3
|
let fast_xml_parser = require("fast-xml-parser");
|
|
5
4
|
//#region src/feeds/atom/parse/config.ts
|
|
6
5
|
const stopNodes = [
|
|
@@ -71,7 +70,7 @@ const stopNodes = [
|
|
|
71
70
|
];
|
|
72
71
|
const parser = new fast_xml_parser.XMLParser({
|
|
73
72
|
...require_config.parserConfig,
|
|
74
|
-
stopNodes
|
|
73
|
+
stopNodes
|
|
75
74
|
});
|
|
76
75
|
const normalizeNamespaces = require_utils.createNamespaceNormalizator(require_config.namespaceUris, require_config.namespacePrefixes, ["atom"]);
|
|
77
76
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { namespacePrefixes, namespaceStopNodes, namespaceUris, parserConfig } from "../../../common/config.js";
|
|
2
2
|
import { createNamespaceNormalizator, expandStopNodes } from "../../../common/utils.js";
|
|
3
|
-
import Expression from "../../../node_modules/path-expression-matcher/src/Expression.js";
|
|
4
3
|
import { XMLParser } from "fast-xml-parser";
|
|
5
4
|
//#region src/feeds/atom/parse/config.ts
|
|
6
5
|
const stopNodes = [
|
|
@@ -71,7 +70,7 @@ const stopNodes = [
|
|
|
71
70
|
];
|
|
72
71
|
const parser = new XMLParser({
|
|
73
72
|
...parserConfig,
|
|
74
|
-
stopNodes
|
|
73
|
+
stopNodes
|
|
75
74
|
});
|
|
76
75
|
const normalizeNamespaces = createNamespaceNormalizator(namespaceUris, namespacePrefixes, ["atom"]);
|
|
77
76
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_config = require("../../../common/config.cjs");
|
|
2
2
|
const require_utils = require("../../../common/utils.cjs");
|
|
3
|
-
const require_Expression = require("../../../node_modules/path-expression-matcher/src/Expression.cjs");
|
|
4
3
|
let fast_xml_parser = require("fast-xml-parser");
|
|
5
4
|
//#region src/feeds/rdf/parse/config.ts
|
|
6
5
|
const stopNodes = [
|
|
@@ -26,7 +25,7 @@ const stopNodes = [
|
|
|
26
25
|
];
|
|
27
26
|
const parser = new fast_xml_parser.XMLParser({
|
|
28
27
|
...require_config.parserConfig,
|
|
29
|
-
stopNodes
|
|
28
|
+
stopNodes
|
|
30
29
|
});
|
|
31
30
|
const normalizeNamespaces = require_utils.createNamespaceNormalizator(require_config.namespaceUris, require_config.namespacePrefixes, ["rdf", "rss"]);
|
|
32
31
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { namespacePrefixes, namespaceStopNodes, namespaceUris, parserConfig } from "../../../common/config.js";
|
|
2
2
|
import { createNamespaceNormalizator, expandStopNodes } from "../../../common/utils.js";
|
|
3
|
-
import Expression from "../../../node_modules/path-expression-matcher/src/Expression.js";
|
|
4
3
|
import { XMLParser } from "fast-xml-parser";
|
|
5
4
|
//#region src/feeds/rdf/parse/config.ts
|
|
6
5
|
const stopNodes = [
|
|
@@ -26,7 +25,7 @@ const stopNodes = [
|
|
|
26
25
|
];
|
|
27
26
|
const parser = new XMLParser({
|
|
28
27
|
...parserConfig,
|
|
29
|
-
stopNodes
|
|
28
|
+
stopNodes
|
|
30
29
|
});
|
|
31
30
|
const normalizeNamespaces = createNamespaceNormalizator(namespaceUris, namespacePrefixes, ["rdf", "rss"]);
|
|
32
31
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_config = require("../../../common/config.cjs");
|
|
2
2
|
const require_utils = require("../../../common/utils.cjs");
|
|
3
|
-
const require_Expression = require("../../../node_modules/path-expression-matcher/src/Expression.cjs");
|
|
4
3
|
let fast_xml_parser = require("fast-xml-parser");
|
|
5
4
|
//#region src/feeds/rss/parse/config.ts
|
|
6
5
|
const sharedStopNodes = [
|
|
@@ -54,7 +53,7 @@ const stopNodes = [
|
|
|
54
53
|
];
|
|
55
54
|
const parser = new fast_xml_parser.XMLParser({
|
|
56
55
|
...require_config.parserConfig,
|
|
57
|
-
stopNodes
|
|
56
|
+
stopNodes
|
|
58
57
|
});
|
|
59
58
|
const normalizeNamespaces = require_utils.createNamespaceNormalizator(require_config.namespaceUris, require_config.namespacePrefixes);
|
|
60
59
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { namespacePrefixes, namespaceStopNodes, namespaceUris, parserConfig } from "../../../common/config.js";
|
|
2
2
|
import { createNamespaceNormalizator, expandStopNodes } from "../../../common/utils.js";
|
|
3
|
-
import Expression from "../../../node_modules/path-expression-matcher/src/Expression.js";
|
|
4
3
|
import { XMLParser } from "fast-xml-parser";
|
|
5
4
|
//#region src/feeds/rss/parse/config.ts
|
|
6
5
|
const sharedStopNodes = [
|
|
@@ -54,7 +53,7 @@ const stopNodes = [
|
|
|
54
53
|
];
|
|
55
54
|
const parser = new XMLParser({
|
|
56
55
|
...parserConfig,
|
|
57
|
-
stopNodes
|
|
56
|
+
stopNodes
|
|
58
57
|
});
|
|
59
58
|
const normalizeNamespaces = createNamespaceNormalizator(namespaceUris, namespacePrefixes);
|
|
60
59
|
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_config = require("../../common/config.cjs");
|
|
2
|
-
const require_Expression = require("../../node_modules/path-expression-matcher/src/Expression.cjs");
|
|
3
2
|
let fast_xml_parser = require("fast-xml-parser");
|
|
4
3
|
//#region src/opml/parse/config.ts
|
|
5
4
|
const stopNodes = [
|
|
@@ -19,7 +18,7 @@ const stopNodes = [
|
|
|
19
18
|
];
|
|
20
19
|
const parser = new fast_xml_parser.XMLParser({
|
|
21
20
|
...require_config.parserConfig,
|
|
22
|
-
stopNodes
|
|
21
|
+
stopNodes
|
|
23
22
|
});
|
|
24
23
|
//#endregion
|
|
25
24
|
exports.parser = parser;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { parserConfig } from "../../common/config.js";
|
|
2
|
-
import Expression from "../../node_modules/path-expression-matcher/src/Expression.js";
|
|
3
2
|
import { XMLParser } from "fast-xml-parser";
|
|
4
3
|
//#region src/opml/parse/config.ts
|
|
5
4
|
const stopNodes = [
|
|
@@ -19,7 +18,7 @@ const stopNodes = [
|
|
|
19
18
|
];
|
|
20
19
|
const parser = new XMLParser({
|
|
21
20
|
...parserConfig,
|
|
22
|
-
stopNodes
|
|
21
|
+
stopNodes
|
|
23
22
|
});
|
|
24
23
|
//#endregion
|
|
25
24
|
export { parser };
|
package/package.json
CHANGED
|
@@ -55,13 +55,13 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"entities": "^7.0.1",
|
|
58
|
-
"fast-xml-parser": "~5.
|
|
58
|
+
"fast-xml-parser": "~5.7.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/bun": "^1.3.12",
|
|
62
62
|
"kvalita": "^1.12.4",
|
|
63
|
-
"tsdown": "^0.21.
|
|
63
|
+
"tsdown": "^0.21.9",
|
|
64
64
|
"vitepress": "^2.0.0-alpha.17"
|
|
65
65
|
},
|
|
66
|
-
"version": "3.0.0-beta.
|
|
66
|
+
"version": "3.0.0-beta.3"
|
|
67
67
|
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
//#region node_modules/path-expression-matcher/src/Expression.js
|
|
2
|
-
/**
|
|
3
|
-
* Expression - Parses and stores a tag pattern expression
|
|
4
|
-
*
|
|
5
|
-
* Patterns are parsed once and stored in an optimized structure for fast matching.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const expr = new Expression("root.users.user");
|
|
9
|
-
* const expr2 = new Expression("..user[id]:first");
|
|
10
|
-
* const expr3 = new Expression("root/users/user", { separator: '/' });
|
|
11
|
-
*/
|
|
12
|
-
var Expression = class {
|
|
13
|
-
/**
|
|
14
|
-
* Create a new Expression
|
|
15
|
-
* @param {string} pattern - Pattern string (e.g., "root.users.user", "..user[id]")
|
|
16
|
-
* @param {Object} options - Configuration options
|
|
17
|
-
* @param {string} options.separator - Path separator (default: '.')
|
|
18
|
-
*/
|
|
19
|
-
constructor(pattern, options = {}, data) {
|
|
20
|
-
this.pattern = pattern;
|
|
21
|
-
this.separator = options.separator || ".";
|
|
22
|
-
this.segments = this._parse(pattern);
|
|
23
|
-
this.data = data;
|
|
24
|
-
this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
|
|
25
|
-
this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== void 0);
|
|
26
|
-
this._hasPositionSelector = this.segments.some((seg) => seg.position !== void 0);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Parse pattern string into segments
|
|
30
|
-
* @private
|
|
31
|
-
* @param {string} pattern - Pattern to parse
|
|
32
|
-
* @returns {Array} Array of segment objects
|
|
33
|
-
*/
|
|
34
|
-
_parse(pattern) {
|
|
35
|
-
const segments = [];
|
|
36
|
-
let i = 0;
|
|
37
|
-
let currentPart = "";
|
|
38
|
-
while (i < pattern.length) if (pattern[i] === this.separator) if (i + 1 < pattern.length && pattern[i + 1] === this.separator) {
|
|
39
|
-
if (currentPart.trim()) {
|
|
40
|
-
segments.push(this._parseSegment(currentPart.trim()));
|
|
41
|
-
currentPart = "";
|
|
42
|
-
}
|
|
43
|
-
segments.push({ type: "deep-wildcard" });
|
|
44
|
-
i += 2;
|
|
45
|
-
} else {
|
|
46
|
-
if (currentPart.trim()) segments.push(this._parseSegment(currentPart.trim()));
|
|
47
|
-
currentPart = "";
|
|
48
|
-
i++;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
currentPart += pattern[i];
|
|
52
|
-
i++;
|
|
53
|
-
}
|
|
54
|
-
if (currentPart.trim()) segments.push(this._parseSegment(currentPart.trim()));
|
|
55
|
-
return segments;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Parse a single segment
|
|
59
|
-
* @private
|
|
60
|
-
* @param {string} part - Segment string (e.g., "user", "ns::user", "user[id]", "ns::user:first")
|
|
61
|
-
* @returns {Object} Segment object
|
|
62
|
-
*/
|
|
63
|
-
_parseSegment(part) {
|
|
64
|
-
const segment = { type: "tag" };
|
|
65
|
-
let bracketContent = null;
|
|
66
|
-
let withoutBrackets = part;
|
|
67
|
-
const bracketMatch = part.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);
|
|
68
|
-
if (bracketMatch) {
|
|
69
|
-
withoutBrackets = bracketMatch[1] + bracketMatch[3];
|
|
70
|
-
if (bracketMatch[2]) {
|
|
71
|
-
const content = bracketMatch[2].slice(1, -1);
|
|
72
|
-
if (content) bracketContent = content;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
let namespace = void 0;
|
|
76
|
-
let tagAndPosition = withoutBrackets;
|
|
77
|
-
if (withoutBrackets.includes("::")) {
|
|
78
|
-
const nsIndex = withoutBrackets.indexOf("::");
|
|
79
|
-
namespace = withoutBrackets.substring(0, nsIndex).trim();
|
|
80
|
-
tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim();
|
|
81
|
-
if (!namespace) throw new Error(`Invalid namespace in pattern: ${part}`);
|
|
82
|
-
}
|
|
83
|
-
let tag = void 0;
|
|
84
|
-
let positionMatch = null;
|
|
85
|
-
if (tagAndPosition.includes(":")) {
|
|
86
|
-
const colonIndex = tagAndPosition.lastIndexOf(":");
|
|
87
|
-
const tagPart = tagAndPosition.substring(0, colonIndex).trim();
|
|
88
|
-
const posPart = tagAndPosition.substring(colonIndex + 1).trim();
|
|
89
|
-
if ([
|
|
90
|
-
"first",
|
|
91
|
-
"last",
|
|
92
|
-
"odd",
|
|
93
|
-
"even"
|
|
94
|
-
].includes(posPart) || /^nth\(\d+\)$/.test(posPart)) {
|
|
95
|
-
tag = tagPart;
|
|
96
|
-
positionMatch = posPart;
|
|
97
|
-
} else tag = tagAndPosition;
|
|
98
|
-
} else tag = tagAndPosition;
|
|
99
|
-
if (!tag) throw new Error(`Invalid segment pattern: ${part}`);
|
|
100
|
-
segment.tag = tag;
|
|
101
|
-
if (namespace) segment.namespace = namespace;
|
|
102
|
-
if (bracketContent) if (bracketContent.includes("=")) {
|
|
103
|
-
const eqIndex = bracketContent.indexOf("=");
|
|
104
|
-
segment.attrName = bracketContent.substring(0, eqIndex).trim();
|
|
105
|
-
segment.attrValue = bracketContent.substring(eqIndex + 1).trim();
|
|
106
|
-
} else segment.attrName = bracketContent.trim();
|
|
107
|
-
if (positionMatch) {
|
|
108
|
-
const nthMatch = positionMatch.match(/^nth\((\d+)\)$/);
|
|
109
|
-
if (nthMatch) {
|
|
110
|
-
segment.position = "nth";
|
|
111
|
-
segment.positionValue = parseInt(nthMatch[1], 10);
|
|
112
|
-
} else segment.position = positionMatch;
|
|
113
|
-
}
|
|
114
|
-
return segment;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get the number of segments
|
|
118
|
-
* @returns {number}
|
|
119
|
-
*/
|
|
120
|
-
get length() {
|
|
121
|
-
return this.segments.length;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Check if expression contains deep wildcard
|
|
125
|
-
* @returns {boolean}
|
|
126
|
-
*/
|
|
127
|
-
hasDeepWildcard() {
|
|
128
|
-
return this._hasDeepWildcard;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Check if expression has attribute conditions
|
|
132
|
-
* @returns {boolean}
|
|
133
|
-
*/
|
|
134
|
-
hasAttributeCondition() {
|
|
135
|
-
return this._hasAttributeCondition;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Check if expression has position selectors
|
|
139
|
-
* @returns {boolean}
|
|
140
|
-
*/
|
|
141
|
-
hasPositionSelector() {
|
|
142
|
-
return this._hasPositionSelector;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get string representation
|
|
146
|
-
* @returns {string}
|
|
147
|
-
*/
|
|
148
|
-
toString() {
|
|
149
|
-
return this.pattern;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
//#endregion
|
|
153
|
-
exports.default = Expression;
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
//#region node_modules/path-expression-matcher/src/Expression.js
|
|
2
|
-
/**
|
|
3
|
-
* Expression - Parses and stores a tag pattern expression
|
|
4
|
-
*
|
|
5
|
-
* Patterns are parsed once and stored in an optimized structure for fast matching.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const expr = new Expression("root.users.user");
|
|
9
|
-
* const expr2 = new Expression("..user[id]:first");
|
|
10
|
-
* const expr3 = new Expression("root/users/user", { separator: '/' });
|
|
11
|
-
*/
|
|
12
|
-
var Expression = class {
|
|
13
|
-
/**
|
|
14
|
-
* Create a new Expression
|
|
15
|
-
* @param {string} pattern - Pattern string (e.g., "root.users.user", "..user[id]")
|
|
16
|
-
* @param {Object} options - Configuration options
|
|
17
|
-
* @param {string} options.separator - Path separator (default: '.')
|
|
18
|
-
*/
|
|
19
|
-
constructor(pattern, options = {}, data) {
|
|
20
|
-
this.pattern = pattern;
|
|
21
|
-
this.separator = options.separator || ".";
|
|
22
|
-
this.segments = this._parse(pattern);
|
|
23
|
-
this.data = data;
|
|
24
|
-
this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
|
|
25
|
-
this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== void 0);
|
|
26
|
-
this._hasPositionSelector = this.segments.some((seg) => seg.position !== void 0);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Parse pattern string into segments
|
|
30
|
-
* @private
|
|
31
|
-
* @param {string} pattern - Pattern to parse
|
|
32
|
-
* @returns {Array} Array of segment objects
|
|
33
|
-
*/
|
|
34
|
-
_parse(pattern) {
|
|
35
|
-
const segments = [];
|
|
36
|
-
let i = 0;
|
|
37
|
-
let currentPart = "";
|
|
38
|
-
while (i < pattern.length) if (pattern[i] === this.separator) if (i + 1 < pattern.length && pattern[i + 1] === this.separator) {
|
|
39
|
-
if (currentPart.trim()) {
|
|
40
|
-
segments.push(this._parseSegment(currentPart.trim()));
|
|
41
|
-
currentPart = "";
|
|
42
|
-
}
|
|
43
|
-
segments.push({ type: "deep-wildcard" });
|
|
44
|
-
i += 2;
|
|
45
|
-
} else {
|
|
46
|
-
if (currentPart.trim()) segments.push(this._parseSegment(currentPart.trim()));
|
|
47
|
-
currentPart = "";
|
|
48
|
-
i++;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
currentPart += pattern[i];
|
|
52
|
-
i++;
|
|
53
|
-
}
|
|
54
|
-
if (currentPart.trim()) segments.push(this._parseSegment(currentPart.trim()));
|
|
55
|
-
return segments;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Parse a single segment
|
|
59
|
-
* @private
|
|
60
|
-
* @param {string} part - Segment string (e.g., "user", "ns::user", "user[id]", "ns::user:first")
|
|
61
|
-
* @returns {Object} Segment object
|
|
62
|
-
*/
|
|
63
|
-
_parseSegment(part) {
|
|
64
|
-
const segment = { type: "tag" };
|
|
65
|
-
let bracketContent = null;
|
|
66
|
-
let withoutBrackets = part;
|
|
67
|
-
const bracketMatch = part.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);
|
|
68
|
-
if (bracketMatch) {
|
|
69
|
-
withoutBrackets = bracketMatch[1] + bracketMatch[3];
|
|
70
|
-
if (bracketMatch[2]) {
|
|
71
|
-
const content = bracketMatch[2].slice(1, -1);
|
|
72
|
-
if (content) bracketContent = content;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
let namespace = void 0;
|
|
76
|
-
let tagAndPosition = withoutBrackets;
|
|
77
|
-
if (withoutBrackets.includes("::")) {
|
|
78
|
-
const nsIndex = withoutBrackets.indexOf("::");
|
|
79
|
-
namespace = withoutBrackets.substring(0, nsIndex).trim();
|
|
80
|
-
tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim();
|
|
81
|
-
if (!namespace) throw new Error(`Invalid namespace in pattern: ${part}`);
|
|
82
|
-
}
|
|
83
|
-
let tag = void 0;
|
|
84
|
-
let positionMatch = null;
|
|
85
|
-
if (tagAndPosition.includes(":")) {
|
|
86
|
-
const colonIndex = tagAndPosition.lastIndexOf(":");
|
|
87
|
-
const tagPart = tagAndPosition.substring(0, colonIndex).trim();
|
|
88
|
-
const posPart = tagAndPosition.substring(colonIndex + 1).trim();
|
|
89
|
-
if ([
|
|
90
|
-
"first",
|
|
91
|
-
"last",
|
|
92
|
-
"odd",
|
|
93
|
-
"even"
|
|
94
|
-
].includes(posPart) || /^nth\(\d+\)$/.test(posPart)) {
|
|
95
|
-
tag = tagPart;
|
|
96
|
-
positionMatch = posPart;
|
|
97
|
-
} else tag = tagAndPosition;
|
|
98
|
-
} else tag = tagAndPosition;
|
|
99
|
-
if (!tag) throw new Error(`Invalid segment pattern: ${part}`);
|
|
100
|
-
segment.tag = tag;
|
|
101
|
-
if (namespace) segment.namespace = namespace;
|
|
102
|
-
if (bracketContent) if (bracketContent.includes("=")) {
|
|
103
|
-
const eqIndex = bracketContent.indexOf("=");
|
|
104
|
-
segment.attrName = bracketContent.substring(0, eqIndex).trim();
|
|
105
|
-
segment.attrValue = bracketContent.substring(eqIndex + 1).trim();
|
|
106
|
-
} else segment.attrName = bracketContent.trim();
|
|
107
|
-
if (positionMatch) {
|
|
108
|
-
const nthMatch = positionMatch.match(/^nth\((\d+)\)$/);
|
|
109
|
-
if (nthMatch) {
|
|
110
|
-
segment.position = "nth";
|
|
111
|
-
segment.positionValue = parseInt(nthMatch[1], 10);
|
|
112
|
-
} else segment.position = positionMatch;
|
|
113
|
-
}
|
|
114
|
-
return segment;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get the number of segments
|
|
118
|
-
* @returns {number}
|
|
119
|
-
*/
|
|
120
|
-
get length() {
|
|
121
|
-
return this.segments.length;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Check if expression contains deep wildcard
|
|
125
|
-
* @returns {boolean}
|
|
126
|
-
*/
|
|
127
|
-
hasDeepWildcard() {
|
|
128
|
-
return this._hasDeepWildcard;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Check if expression has attribute conditions
|
|
132
|
-
* @returns {boolean}
|
|
133
|
-
*/
|
|
134
|
-
hasAttributeCondition() {
|
|
135
|
-
return this._hasAttributeCondition;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Check if expression has position selectors
|
|
139
|
-
* @returns {boolean}
|
|
140
|
-
*/
|
|
141
|
-
hasPositionSelector() {
|
|
142
|
-
return this._hasPositionSelector;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get string representation
|
|
146
|
-
* @returns {string}
|
|
147
|
-
*/
|
|
148
|
-
toString() {
|
|
149
|
-
return this.pattern;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
//#endregion
|
|
153
|
-
export { Expression as default };
|