@@ -19,23 +19,41 @@ import {
1919 */
2020export default class ParsedHedGroup extends ParsedHedSubstring {
2121 /**
22- * The parsed HED tags or parsedHedGroups or parsedColumnSplices in the HED tag group at the top level
22+ * The parsed HED tags, groups, or splices in the HED tag group at the top level.
2323 * @type {ParsedHedSubstring[] }
2424 */
2525 tags
2626
27+ /**
28+ * The top-level parsed HED tags in this string.
29+ * @type {ParsedHedTag[] }
30+ */
2731 topTags
2832
33+ /**
34+ * The top-level parsed HED groups in this string.
35+ * @type {ParsedHedGroup[] }
36+ */
2937 topGroups
3038
39+ /**
40+ * The top-level column splices in this string
41+ * @type {ParsedHedColumnSplice[] }
42+ */
3143 topSplices
3244
45+ /**
46+ * All the parsed HED tags in this string.
47+ * @type {ParsedHedTag[] }
48+ */
3349 allTags
50+
3451 /**
35- * Any HED tags with special handling. This only covers top-level tags in the group
52+ * Any HED tags with special handling. This only covers top-level tags in the group.
3653 * @type {Map<string, ParsedHedTag[]> }
3754 */
3855 specialTags
56+
3957 /**
4058 * Whether this HED tag group has child groups with a Def-expand tag.
4159 * @type {boolean }
@@ -48,12 +66,28 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
4866 */
4967 defExpandChildren
5068
69+ /**
70+ * True if this group has a Def-expand tag at the top level.
71+ * @type {boolean }
72+ */
5173 isDefExpandGroup
5274
75+ /**
76+ * True if this group has a Definition tag at the top level.
77+ * @type {boolean }
78+ */
5379 isDefinitionGroup
5480
81+ /**
82+ * The total number of top-level Def tags and top-level Def-expand groups.
83+ * @type {Number }
84+ */
5585 defCount
5686
87+ /**
88+ * The unique top-level tag requiring a Def or Def-expand group, if any.
89+ * @type {ParsedHedTag | null }
90+ */
5791 requiresDefTag
5892
5993 /**
@@ -74,11 +108,20 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
74108 this . _initializeGroups ( )
75109 }
76110
111+ /**
112+ * Recursively create a list of all the tags in this group.
113+ * @returns {ParsedHedTag[] }
114+ * @private
115+ */
77116 _getAllTags ( ) {
78117 const subgroupTags = this . topGroups . flatMap ( ( tagGroup ) => tagGroup . allTags )
79118 return this . topTags . concat ( subgroupTags )
80119 }
81120
121+ /**
122+ * Sets information about the special tags, particularly definition-related tags in this group.
123+ * @private
124+ */
82125 _initializeGroups ( ) {
83126 const special = ReservedChecker . getInstance ( )
84127 this . specialTags = categorizeTagsByName ( this . topTags , special . specialNames )
@@ -91,10 +134,11 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
91134 }
92135
93136 /**
94- * Filter top subgroups that include a special at the top-level of the group
137+ * Filter top subgroups that include a special at the top-level of the group.
95138 *
96139 * @param {string } tagName - The schemaTag name to filter by.
97140 * @returns {Array } - Array of subgroups containing the specified tag.
141+ * @private
98142 */
99143 _filterSubgroupsByTagName ( tagName ) {
100144 return Array . from ( this . topLevelGroupIterator ( ) ) . filter ( ( subgroup ) => subgroup . specialTags . has ( tagName ) )
@@ -147,18 +191,6 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
147191 return this . specialTags . get ( tagName ) ?? [ ]
148192 }
149193
150- isSpecialGroup ( tagName ) {
151- return this . specialTags . has ( tagName )
152- }
153-
154- /**
155- * Whether this HED tag group is an onset, offset, or inset group.
156- * @returns {boolean }
157- */
158- get isTemporalGroup ( ) {
159- return this . isSpecialGroup ( 'Onset' ) || this . isSpecialGroup ( 'Offset' ) || this . isSpecialGroup ( 'Inset' )
160- }
161-
162194 get defTags ( ) {
163195 const tags = this . getSpecial ( 'Def' )
164196 for ( const group of this . defExpandChildren ) {
@@ -178,22 +210,6 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
178210 )
179211 }
180212
181- /**
182- * The deeply nested array of parsed tags.
183- * @returns {ParsedHedTag[] }
184- */
185- nestedGroups ( ) {
186- const groups = [ ]
187- for ( const innerTag of this . tags ) {
188- if ( innerTag instanceof ParsedHedTag ) {
189- groups . push ( innerTag )
190- } else if ( innerTag instanceof ParsedHedGroup ) {
191- groups . push ( innerTag . nestedGroups ( ) )
192- }
193- }
194- return groups
195- }
196-
197213 /**
198214 * Return a normalized string representation
199215 * @returns {string }
@@ -220,20 +236,6 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
220236 return `(${ sortedNormalizedItems . join ( ',' ) } )` // Using curly braces to indicate unordered group
221237 }
222238
223- /**
224- * Iterator over the full HED groups and subgroups in this HED tag group.
225- *
226- * @yields {ParsedHedTag[]} The subgroups of this tag group.
227- */
228- * subGroupArrayIterator ( ) {
229- for ( const innerTag of this . tags ) {
230- if ( innerTag instanceof ParsedHedGroup ) {
231- yield * innerTag . subGroupArrayIterator ( )
232- }
233- }
234- yield this . tags
235- }
236-
237239 /**
238240 * Iterator over the ParsedHedGroup objects in this HED tag group.
239241 * @param {string | null } tagName - The name of the tag whose groups are to be iterated over or null if all tags.
0 commit comments