Skip to content

Add TypeScript class declaration for ParsedHedSubstring #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/parser/parsedHedSubstring.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
declare abstract class ParsedHedSubstring {
/**
* The original pre-parsed version of the HED tag.
*/
originalTag: string
/**
* The bounds of the HED tag in the original HED string.
*/
originalBounds: number[]

/**
* Constructor.
* @param originalTag The original HED tag.
* @param originalBounds The bounds of the HED tag in the original HED string.
*/
protected constructor(originalTag: string, originalBounds: number[])

/**
* Nicely format this substring. This is left blank for the subclasses to override.
*
* This is left blank for the subclasses to override.
*
* @param long Whether the tags should be in long form.
*/
public abstract format(long: boolean): string

/**
* Get the normalized version of the object.
*/
public abstract get normalized(): string

/**
* Override of {@link Object.prototype.toString}.
*
* @returns The original form of this HED substring.
*/
public toString(): string
}

export = ParsedHedSubstring
42 changes: 0 additions & 42 deletions src/parser/parsedHedSubstring.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,11 @@
* A parsed HED substring.
*/
export class ParsedHedSubstring {
/**
* The original pre-parsed version of the HED tag.
* @type {string}
*/
originalTag
/**
* The bounds of the HED tag in the original HED string.
* @type {int[]}
*/
originalBounds

/**
* Constructor.
* @param {string} originalTag The original HED tag.
* @param {number[]} originalBounds The bounds of the HED tag in the original HED string.
*/
constructor(originalTag, originalBounds) {
this.originalTag = originalTag
this.originalBounds = originalBounds
}

/**
* Nicely format this substring. This is left blank for the subclasses to override.
*
* This is left blank for the subclasses to override.
*
* @param {boolean} long - Whether the tags should be in long form.
* @returns {string}
* @abstract
*/
format(long = true) {}

/**
* Get the normalized version of the object.
*
* @returns {string}
* @abstract
*/
get normalized() {
return ''
}

/**
* Override of {@link Object.prototype.toString}.
*
* @returns {string} The original form of this HED substring.
*/
toString() {
return this.originalTag
}
Expand Down
Loading