diff --git a/validator/parser/parsedHedGroup.js b/validator/parser/parsedHedGroup.js index 712d0e9b..a631ba26 100644 --- a/validator/parser/parsedHedGroup.js +++ b/validator/parser/parsedHedGroup.js @@ -155,7 +155,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Whether this HED tag group is an inset group. - * @return {boolean} + * @returns {boolean} */ get isInsetGroup() { return this.specialTags.has('Inset') @@ -163,7 +163,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Whether this HED tag group is an onset, offset, or inset group. - * @return {boolean} + * @returns {boolean} */ get isTemporalGroup() { return this.isOnsetGroup || this.isOffsetGroup || this.isInsetGroup @@ -171,7 +171,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Whether this HED tag group is an onset, offset, or inset group. - * @return {string} + * @returns {string} */ get temporalGroupName() { if (this.isOnsetGroup) { @@ -188,7 +188,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Find what should be the sole definition tag, or throw an error if more than one is found. * - * @return {ParsedHedTag} This group's definition tag. + * @returns {ParsedHedTag} This group's definition tag. */ get definitionTag() { return this.getSingleDefinitionTag('definitionTag', 'Definition') @@ -197,7 +197,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Find what should be the sole {@code Def-expand} tag, or throw an error if more than one is found. * - * @return {ParsedHedTag} This group's {@code Def-expand} tag. + * @returns {ParsedHedTag} This group's {@code Def-expand} tag. */ get defExpandTag() { return this.getSingleDefinitionTag('defExpandTag', 'Def-expand') @@ -237,7 +237,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the name of this group's definition. - * @return {string|null} + * @returns {string|null} */ get definitionName() { return this.getSingleDefinitionName('definitionName', 'Definition') @@ -245,7 +245,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the name of this group's definition. - * @return {string|null} + * @returns {string|null} */ get defExpandName() { return this.getSingleDefinitionName('defExpandName', 'Def-expand') @@ -265,7 +265,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the value of this group's definition. - * @return {string|null} + * @returns {string|null} */ get definitionValue() { return this.getSingleDefinitionValue('definitionValue', 'Definition') @@ -273,7 +273,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the value of this group's definition. - * @return {string|null} + * @returns {string|null} */ get defExpandValue() { return this.getSingleDefinitionValue('defExpandValue', 'Def-expand') @@ -290,7 +290,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the name and value of this group's definition. - * @return {string|null} + * @returns {string|null} */ get definitionNameAndValue() { return this.getSingleDefinitionNameAndValue('definition', 'Definition') @@ -298,7 +298,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the name and value of this group's definition. - * @return {string|null} + * @returns {string|null} */ get defExpandNameAndValue() { return this.getSingleDefinitionNameAndValue('defExpand', 'Def-expand') @@ -322,7 +322,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the name(s) of this group's definition. - * @return {string|string[]|null} + * @returns {string|string[]|null} */ get defName() { return this._memoize('defName', () => { @@ -349,7 +349,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the name of this group's definition. - * @return {string|null} + * @returns {string|null} */ get defValue() { return this._memoize('defValue', () => { @@ -376,7 +376,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the name and value of this group's {@code Def} or {@code Def-expand}. - * @return {string|null} + * @returns {string|null} */ get defNameAndValue() { return this._memoize('defNameAndValue', () => { @@ -395,7 +395,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { * * @param {ParsedHedTag} tag A definition-type tag. * @param {string} parentTag The expected parent of the tag. - * @return {string} The parameterized value of the definition, or an empty string if no value was found. + * @returns {string} The parameterized value of the definition, or an empty string if no value was found. */ static getDefinitionTagValue(tag, parentTag) { if (getTagName(tag.parentCanonicalTag) === parentTag) { @@ -407,7 +407,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the value of this group's definition. - * @return {ParsedHedGroup|null} + * @returns {ParsedHedGroup|null} */ get definitionGroup() { return this._memoize('definitionGroup', () => { @@ -425,7 +425,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Determine the number of {@code Def} and {@code Def-expand} tag/tag groups included in this group. - * @return {number} The number of first-level definition reference tags and tag groups in this group. + * @returns {number} The number of first-level definition reference tags and tag groups in this group. */ get defCount() { return this._memoize('defCount', () => { @@ -446,7 +446,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * The deeply nested array of parsed tags. - * @return {ParsedHedTag[]} + * @returns {ParsedHedTag[]} */ nestedGroups() { const currentGroup = [] @@ -463,7 +463,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Iterator over the full HED groups and subgroups in this HED tag group. * - * @yield {ParsedHedTag[]} The subgroups of this tag group. + * @yields {ParsedHedTag[]} The subgroups of this tag group. */ *subGroupArrayIterator() { const currentGroup = [] @@ -480,7 +480,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Iterator over the ParsedHedGroup objects in this HED tag group. * - * @yield {ParsedHedGroup} This object and the ParsedHedGroup objects belonging to this tag group. + * @yields {ParsedHedGroup} This object and the ParsedHedGroup objects belonging to this tag group. */ *subParsedGroupIterator() { yield this @@ -494,29 +494,34 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Iterator over the parsed HED tags in this HED tag group. * - * @yield {ParsedHedTag} This tag group's HED tags. + * @yields {ParsedHedTag} This tag group's HED tags. */ *tagIterator() { - for (const innerTag of this.tags) { - if (innerTag instanceof ParsedHedTag) { - yield innerTag - } else if (innerTag instanceof ParsedHedGroup) { - yield* innerTag.tagIterator() - } - } + yield* this._innerTagIterator(ParsedHedTag) } /** * Iterator over the parsed HED column splices in this HED tag group. * - * @yield {ParsedHedColumnSplice} This tag group's HED column splices. + * @yields {ParsedHedColumnSplice} This tag group's HED column splices. */ *columnSpliceIterator() { + yield* this._innerTagIterator(ParsedHedColumnSplice) + } + + /** + * Implementation of {@link tagIterator} and {@link columnSpliceIterator}. + * + * @param {typeof ParsedHedSubstring} InnerTagClass Type of inner tag to return. + * @yields {ParsedHedSubstring} + * @private + */ + *_innerTagIterator(InnerTagClass) { for (const innerTag of this.tags) { - if (innerTag instanceof ParsedHedColumnSplice) { + if (innerTag instanceof InnerTagClass) { yield innerTag } else if (innerTag instanceof ParsedHedGroup) { - yield* innerTag.columnSpliceIterator() + yield* innerTag._innerTagIterator(InnerTagClass) } } } @@ -524,7 +529,7 @@ export class ParsedHedGroup extends ParsedHedSubstring { /** * Iterator over the top-level parsed HED groups in this HED tag group. * - * @yield {ParsedHedTag} This tag group's top-level HED groups. + * @yields {ParsedHedTag} This tag group's top-level HED groups. */ *topLevelGroupIterator() { for (const innerTag of this.tags) {