From a8b77966a94cb7fa702330d00c654e69b7a99aa3 Mon Sep 17 00:00:00 2001 From: Yaman Qassas Date: Fri, 2 Jul 2021 19:33:09 +0300 Subject: [PATCH 1/2] remove trailing whitespaces --- .github/workflows/github-pages.yml | 4 ++-- src/index.ts | 2 +- src/items-merger.ts | 16 ++++++++-------- src/items-shaper.ts | 4 ++-- src/mark-record.ts | 2 +- src/marks-extractor.ts | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 4c09ea9..57fd195 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -24,10 +24,10 @@ jobs: uses: actions/setup-node@v2.2.0 with: node-version: 14.x - + - name: Install the dependencies run: yarn - + - name: Generate the documentation run: yarn docs diff --git a/src/index.ts b/src/index.ts index a489273..0621b71 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,7 +50,7 @@ export async function extractMarksFromDocument(document: PDFDocumentProxy): Prom /** * Loads a PDF document and extracts the marks records from it. - * + * * @param src Can be a URL where a PDF file is located, a typed array (Uint8Array) * already populated with data, or a parameter object. * @returns The extracted marks records. diff --git a/src/items-merger.ts b/src/items-merger.ts index 5eb0d33..c3bab70 100644 --- a/src/items-merger.ts +++ b/src/items-merger.ts @@ -2,16 +2,16 @@ import { SimpleTextItem } from './simple-text-item'; /** * Represents a row of sorted items, which can be iterated for each item. - * + * * The items are sorted in ascending order by their X coordinates (which is page-left based). - * + * * This is essential for the items merging algorithm. */ class SortedRow implements Iterable { /** * Construct a new row of items view. - * + * * @param items The items array to take a section from, * it should be sorted in ascending order by Y coordinates then by X coordinates. * @param fromIndex The index of the first item included in the view section. @@ -38,9 +38,9 @@ class SortedRow implements Iterable { /** * Represents a page of sorted items, which can be iterated for each row of items. - * + * * The items rows are sorted in ascending order by their Y coordinates (which is page-bottom based). - * + * * This is essential for the items merging algorithm. */ class SortedPage implements Iterable { @@ -84,7 +84,7 @@ class SortedPage implements Iterable { /** * Checks whether the item is protected from being merged with other items or not. - * + * * @param item The item to check. * @returns Whether the item is protected or not. */ @@ -95,7 +95,7 @@ function isItemProtected(item: SimpleTextItem): boolean { /** * Checks whether 2 items should be merged or not. - * + * * @param itemA The first item to check, which should be to the left (lower X coordinates). * @param itemB The second item to check, which should be to the right (higher X cordinates). * @returns Whether the items should be merged or not. @@ -112,7 +112,7 @@ function shouldBeMerged(itemA: SimpleTextItem, itemB: SimpleTextItem): boolean { /** * Merges close Arabic simplified text items into single items. * The original list is left unmodified. - * + * * @param items The list of simplified text items. * @returns A new list of the text items after merging close Arabic items. */ diff --git a/src/items-shaper.ts b/src/items-shaper.ts index f82bc7d..de238dd 100644 --- a/src/items-shaper.ts +++ b/src/items-shaper.ts @@ -45,7 +45,7 @@ class TablePage implements Iterable { /** * Checks if the projects of 2 items on the Y axis intersect. - * + * * @param itemA The first item to check. * @param itemB The second item to check. * @returns Whether their projections on the Y axis intersect or not. @@ -60,7 +60,7 @@ class TablePage implements Iterable { /** * Groups the list of items into a table structure. - * + * * @param items The target list of simplified text items. * @returns A 2-dimensional array of the text items, * where the first dimension is for the able rows, diff --git a/src/mark-record.ts b/src/mark-record.ts index 7418cfb..255d544 100644 --- a/src/mark-record.ts +++ b/src/mark-record.ts @@ -1,6 +1,6 @@ /** * Represents a mark record extracted from the document. - * + * * All the fields (except the `studentId`) can be `null` because they might be missing from the table, or malformed with other values. */ export interface MarkRecord { diff --git a/src/marks-extractor.ts b/src/marks-extractor.ts index ad08c5c..197572b 100644 --- a/src/marks-extractor.ts +++ b/src/marks-extractor.ts @@ -3,7 +3,7 @@ import { MarkRecord } from './mark-record'; /** * Extracts marks records from a table of simplified text items. - * + * * @param itemsTable The simplified items table to extract marks from. * @returns The extracted marks records. */ From 106250753a00e3a1c8d817be3c3f7fa257ada1cf Mon Sep 17 00:00:00 2001 From: Yaman Qassas Date: Fri, 2 Jul 2021 19:33:54 +0300 Subject: [PATCH 2/2] add radix parameter to parseInt --- src/marks-extractor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/marks-extractor.ts b/src/marks-extractor.ts index 197572b..cc3eed5 100644 --- a/src/marks-extractor.ts +++ b/src/marks-extractor.ts @@ -19,7 +19,7 @@ export function extractMarksFromItemsTable(itemsTable: readonly (readonly Readon // Create the record. const record: MarkRecord = { - studentId: Number.parseInt(studentIdItem.value), + studentId: Number.parseInt(studentIdItem.value, 10), studentName: null, studentFatherName: null, practicalMark: null, @@ -43,7 +43,7 @@ export function extractMarksFromItemsTable(itemsTable: readonly (readonly Readon else if (record.studentFatherName === null) record.studentFatherName = value.trim(); } - if (isMark && marks.length < 3) marks.push(Number.parseInt(value)); + if (isMark && marks.length < 3) marks.push(Number.parseInt(value, 10)); } if (marks.length === 1)