diff --git a/.eslintrc b/.eslintrc index 6c708ff..f9076dd 100644 --- a/.eslintrc +++ b/.eslintrc @@ -64,6 +64,7 @@ "@typescript-eslint/return-await": ["error", "in-try-catch"], "jsdoc/require-param-type": 0, "jsdoc/require-returns-type": 0, + "jsdoc/no-undefined-types": 0, "jsdoc/require-jsdoc": [ "error", { diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4674156..f76c8f5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,6 +11,9 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Enable Corepack + run: corepack enable + - name: Set Node.js 16.x uses: actions/setup-node@v3 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fdad15..c0ea266 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,9 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Enable Corepack + run: corepack enable + - name: Set Node.js 16.x uses: actions/setup-node@v3 with: diff --git a/src/formats/html.ts b/src/formats/html.ts index d5a2b37..074a6f6 100644 --- a/src/formats/html.ts +++ b/src/formats/html.ts @@ -27,7 +27,6 @@ type HTMLSegmentPart = { /** * Determines if the value of data is a valid HTML transcript format - * * @param data The transcript data * @returns True: data is valid HTML transcript format */ @@ -42,7 +41,6 @@ export const isHTML = (data: string): boolean => { /** * Updates HTML Segment parts if expected HTML segment - * * @param element HTML segment to check * @param segmentPart Current segment parts * @returns Updated HTML Segment part and segment data for next segment (if fields encountered) @@ -85,7 +83,6 @@ const updateSegmentPartFromElement = ( /** * Create Segment from HTML segment parts - * * @param segmentPart HTML segment data * @param lastSpeaker Name of last speaker. Will be used if no speaker found in `segmentLines` * @returns Created segment @@ -106,7 +103,6 @@ const createSegmentFromSegmentPart = (segmentPart: HTMLSegmentPart, lastSpeaker: /** * Parse HTML data and create {@link Segment} for each segment data found in data - * * @param elements HTML elements containing transcript data * @returns Segments created from HTML data */ @@ -168,7 +164,6 @@ const getSegmentsFromHTMLElements = (elements: Array): Array { /** * Parse JSON data where segments are in the `segments` Array and in the {@link JSONSegment} format - * * @param data Parsed JSON data * @returns An array of Segments from the parsed data */ @@ -95,7 +93,6 @@ const parseDictSegmentsJSON = (data: JSONTranscript): Array => { /** * Parse JSON data where top level item is a dict/object - * * @param data The transcript data * @returns An array of Segments from the parsed data * @throws {TypeError} When JSON data does not match one of the valid formats @@ -118,7 +115,6 @@ const parseDictJSON = (data: object): Array => { /** * Convert {@link SubtitleSegment} to the {@link Segment} format used here - * * @param data Segment parsed from JSON data * @returns Segment representing `data`. * Returns {@link undefined} when data does not match {@link SubtitleSegment} format. @@ -151,7 +147,6 @@ const getSegmentFromSubtitle = (data: SubtitleSegment): Segment => { /** * Parse JSON data where items in data are in the {@link SubtitleSegment} format - * * @param data Parsed JSON data * @returns An array of Segments from the parsed data * @throws {TypeError} When item in `data` does not match the {@link SubtitleSegment} format @@ -178,7 +173,6 @@ const parseListJSONSubtitle = (data: Array): Array => /** * Parse JSON data where top level item is an Array - * * @param data The transcript data * @returns An array of Segments from the parsed data * @throws {TypeError} When JSON data does not match one of the valid formats @@ -202,7 +196,6 @@ const parseListJSON = (data: Array): Array => { /** * Parse JSON data to an Array of {@link Segment} - * * @param data The transcript data * @returns An array of Segments from the parsed data * @throws {TypeError} When `data` is not valid JSON format diff --git a/src/formats/srt.ts b/src/formats/srt.ts index 51b9b37..993a61f 100644 --- a/src/formats/srt.ts +++ b/src/formats/srt.ts @@ -31,7 +31,6 @@ export type SRTSegment = { /** * Parse lines looking for data to be SRT format - * * @param lines Lines containing SRT data * @param indexOptional if true and index line does not exist, don't raise error. Return value will be -1. * @returns Parsed segment @@ -99,7 +98,6 @@ export const parseSRTSegment = (lines: Array, indexOptional = false): SR /** * Create Segment from lines containing an SRT segment/cue - * * @param segmentLines Lines containing SRT data * @param lastSpeaker Name of last speaker. Will be used if no speaker found in `segmentLines` * @param dataIsVTT the data is VTT formatted. Enables handling of minor differences between SRT and VTT @@ -120,7 +118,6 @@ const createSegmentFromSRTLines = (segmentLines: Array, lastSpeaker: str /** * Determines if the value of data is a valid SRT transcript format - * * @param data The transcript data * @param dataIsVTT the data is VTT formatted. Enables handling of minor differences between SRT and VTT * @returns True: data is valid SRT transcript format @@ -136,7 +133,6 @@ export const isSRT = (data: string, dataIsVTT = false): boolean => { /** * Parse SRT data to an Array of {@link Segment} - * * @param data The transcript data * @param dataIsVTT the data is VTT formatted. Enables handling of minor differences between SRT and VTT * @returns An array of Segments from the parsed data diff --git a/src/formats/vtt.ts b/src/formats/vtt.ts index 7da1cd6..994341c 100644 --- a/src/formats/vtt.ts +++ b/src/formats/vtt.ts @@ -9,7 +9,6 @@ const WEBVTT_HEADER = "WEBVTT" /** * Determines if the value of data is a valid VTT transcript format - * * @param data The transcript data * @returns True: data is valid VTT transcript format */ @@ -19,7 +18,6 @@ export const isVTT = (data: string): boolean => { /** * Parse VTT data to an Array of {@link Segment} - * * @param data The transcript data * @returns An array of Segments from the parsed data * @throws {TypeError} When `data` is not valid VTT format diff --git a/src/index.ts b/src/index.ts index 5629dd1..c2b47c9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,6 @@ export { Options, IOptions } from "./options" /** * Determines the format of transcript by inspecting the data - * * @param data The transcript data * @returns The determined transcript format * @throws {TypeError} Cannot determine format of data or error parsing data @@ -39,7 +38,6 @@ export const determineFormat = (data: string): TranscriptFormat => { /** * Convert the data to an Array of {@link Segment} - * * @param data The transcript data * @param transcriptFormat The format of the data. * @returns An Array of Segment objects from the parsed data diff --git a/src/options.ts b/src/options.ts index f58b97a..9a7e30f 100644 --- a/src/options.ts +++ b/src/options.ts @@ -2,7 +2,6 @@ import { DEFAULT_COMBINE_SEGMENTS_LENGTH } from "./types" /** * Verifies the type of the value matches the expected type - * * @param name name of option to check value for * @param expectedType expected type off the value for the option * @param value value to check @@ -140,7 +139,6 @@ export class OptionsManager implements IOptions { /** * Get option value from it's name - * * @param name name of option to get * @returns value of option. If unknown, returns undefined */ @@ -173,7 +171,6 @@ export class OptionsManager implements IOptions { /** * Set option value using it's name - * * @param name name of option to set * @param value value to set option to */ @@ -227,7 +224,6 @@ export class OptionsManager implements IOptions { /** * Set one or more options - * * @param options the options to set * @param setDefault true: set all values to the default before setting values specified by `options` */ @@ -245,7 +241,6 @@ export class OptionsManager implements IOptions { /** * Helper to determine if at least one option should be applied - * * @returns true: at least one option set */ public optionsSet = (): boolean => { diff --git a/src/segments.ts b/src/segments.ts index 6e98634..6d6ca31 100644 --- a/src/segments.ts +++ b/src/segments.ts @@ -13,7 +13,6 @@ const PATTERN_TRAILING_SPACE = /^ *$/ /** * Remove any trailing space characters from data - * * @param data text to trim * @returns text with any trailing space character removed */ @@ -25,7 +24,6 @@ const trimEndSpace = (data: string): string => { * Append `addition` to `body` with the character(s) specified. * * If `addition` matches the {@link PATTERN_PUNCTUATIONS} pattern, no character is added before the additional data. - * * @param body Current body text * @param addition Additional text to add to `body` * @param separator Character(s) to use to separate data. If undefined, uses `\n`. @@ -44,7 +42,6 @@ const joinBody = (body: string, addition: string, separator: string = undefined) /** * Combine one or more {@link Segment} - * * @param segments Array of Segment objects to combine * @param bodySeparator Character(s) to use to separate body data. If undefined, uses `\n`. * @returns Combined segment where: @@ -89,13 +86,12 @@ type CombineResult = { * Checks if the new and prior segments have the same speaker. * * If so, combines segments where: - * - `startTime`: from priorSegment - * - `startTimeFormatted`: from priorSegment - * - `endTime`: from newSegment - * - `endTimeFormatted`: from newSegment - * - `speaker`: from priorSegment - * - `body`: body of priorSegment with body of newSegment separated with space - * + * - `startTime`: from priorSegment + * - `startTimeFormatted`: from priorSegment + * - `endTime`: from newSegment + * - `endTimeFormatted`: from newSegment + * - `speaker`: from priorSegment + * - `body`: body of priorSegment with body of newSegment separated with space * @param newSegment segment being created * @param priorSegment prior parsed segment * @param lastSpeaker last speaker name. @@ -123,13 +119,12 @@ const doCombineSpeaker = (newSegment: Segment, priorSegment: Segment, lastSpeake * max length * * If so, combines segments where: - * - `startTime`: from priorSegment - * - `startTimeFormatted`: from priorSegment - * - `endTime`: from newSegment - * - `endTimeFormatted`: from newSegment - * - `speaker`: from priorSegment - * - `body`: body of priorSegment with body of newSegment separated with space - * + * - `startTime`: from priorSegment + * - `startTimeFormatted`: from priorSegment + * - `endTime`: from newSegment + * - `endTimeFormatted`: from newSegment + * - `speaker`: from priorSegment + * - `body`: body of priorSegment with body of newSegment separated with space * @param newSegment segment being created * @param priorSegment prior parsed segment * @param maxLength maximum allowed length of combined body. If undefined, uses {@link DEFAULT_COMBINE_SEGMENTS_LENGTH} @@ -175,13 +170,12 @@ const doCombineSegments = ( * Checks if the new and prior segments have the same speaker, startTime and endTime. * * If so, combines segments where: - * - `startTime`: from priorSegment - * - `startTimeFormatted`: from priorSegment - * - `endTime`: from newSegment - * - `endTimeFormatted`: from newSegment - * - `speaker`: from priorSegment - * - `body`: body of priorSegment with body of newSegment separated with value of separator argument - * + * - `startTime`: from priorSegment + * - `startTimeFormatted`: from priorSegment + * - `endTime`: from newSegment + * - `endTimeFormatted`: from newSegment + * - `speaker`: from priorSegment + * - `body`: body of priorSegment with body of newSegment separated with value of separator argument * @param newSegment segment being created * @param priorSegment prior parsed segment * @param separator string to use to combine body values. If undefined, uses "\n" @@ -220,13 +214,12 @@ const doCombineEqualTimes = ( * Checks if the new and prior segments have the same speaker. If so, sets the speaker value to undefined * * If so, combines segments where: - * - `startTime`: from priorSegment - * - `startTimeFormatted`: from priorSegment - * - `endTime`: from newSegment - * - `endTimeFormatted`: from newSegment - * - `speaker`: from newSegment if different from priorSegment else undefined - * - `body`: body of priorSegment with body of newSegment separated with space - * + * - `startTime`: from priorSegment + * - `startTimeFormatted`: from priorSegment + * - `endTime`: from newSegment + * - `endTimeFormatted`: from newSegment + * - `speaker`: from newSegment if different from priorSegment else undefined + * - `body`: body of priorSegment with body of newSegment separated with space * @param newSegment segment being created * @param priorSegment prior parsed segment. For the first segment, this shall be undefined. * @param lastSpeaker last speaker name. @@ -279,7 +272,6 @@ const doSpeakerChange = (newSegment: Segment, priorSegment: Segment, lastSpeaker /** * Determine how {@link Options.speakerChange is applied based an past options being applied} - * * @param currentResult current result object from any prior options * @param priorSegment prior parsed segment * @param lastSpeaker last speaker name. @@ -317,7 +309,6 @@ const applyOptionsAndDoSpeakerChange = ( * Apply convert rules when no prior segment exits. * * NOTE: not all rules applicable when no prior segment - * * @param newSegment segment before any rules options to it * @param lastSpeaker last speaker name. * Used when speaker in segment has been removed via {@link Options.speakerChange} rule @@ -339,7 +330,6 @@ const doCombineNoPrior = (newSegment: Segment, lastSpeaker: string): CombineResu /** * Apply convert rules when prior segment exits. - * * @param newSegment segment before any rules options to it * @param priorSegment prior parsed segment * @param lastSpeaker last speaker name. @@ -397,7 +387,6 @@ const doCombineWithPrior = (newSegment: Segment, priorSegment: Segment, lastSpea /** * Apply any options to the current segment - * * @param newSegment segment before any rules options to it * @param priorSegment prior parsed segment. For the first segment, this shall be undefined. * @param lastSpeaker last speaker name. @@ -426,7 +415,6 @@ const applyOptions = (newSegment: Segment, priorSegment: Segment, lastSpeaker: s /** * Get the last speaker name from the previously parsed segments - * * @param priorSegment prior parsed segment * @param priorSegments array of all previous segments * @returns the name of the last speaker @@ -450,7 +438,6 @@ const getLastSpeaker = (priorSegment: Segment, priorSegments: Array): s /** * Helper for adding segment to or updating last segment in array of segments - * * @param newSegment segment to add or replace * @param priorSegments array of all previous segments * @returns updated array of segments with new segment added or last segment updated (per options) diff --git a/src/speaker.ts b/src/speaker.ts index b42ef59..0fb0cb0 100644 --- a/src/speaker.ts +++ b/src/speaker.ts @@ -7,7 +7,6 @@ const PATTERN_SPEAKER = /^(?[a-z].+?): (?.*)/i * Attempt to extract the speaker's name from the data. * * Looks for the strings in the format matching {@link PATTERN_SPEAKER} - * * @param data Data to get speaker from * @returns The speaker (if found) and the remaining string */ diff --git a/src/timestamp.ts b/src/timestamp.ts index c20bbf1..656f261 100644 --- a/src/timestamp.ts +++ b/src/timestamp.ts @@ -7,7 +7,6 @@ const PATTERN_TIMESTAMP = /^(?