Solved type issues in traverseOperations etc. Changed functions to take a object single parameter. Condensed endpoints into a function call

This commit is contained in:
Saud Fatayerji
2023-11-14 03:26:42 +03:00
parent 77274e6117
commit 9956367384
18 changed files with 377 additions and 260 deletions

View File

@@ -6,10 +6,15 @@ import { getImagesOnPage } from "./common/getImagesOnPage.js";
import { selectPages } from "./subDocumentFunctions";
import { PdfFile } from '../wrappers/PdfFile.js';
export async function splitOn(
file: PdfFile,
type: "BAR_CODE"|"QR_CODE"|"BLANK_PAGE",
whiteThreashold: number) {
export type SplitOnParamsType = {
file: PdfFile;
type: "BAR_CODE"|"QR_CODE"|"BLANK_PAGE";
whiteThreashold: number;
}
export async function splitOn(params: SplitOnParamsType) {
const { file, type, whiteThreashold } = params;
let splitAtPages: number[] = [];
switch (type) {
@@ -43,7 +48,7 @@ export async function splitOn(
console.log(i);
if(i == splitAfter) {
if(pagesArray.length > 0) {
subDocuments.push(await selectPages(file, pagesArray));
subDocuments.push(await selectPages({file, pagesToExtractArray:pagesArray}));
pagesArray = [];
}
splitAfter = splitAtPages.shift();
@@ -54,7 +59,7 @@ export async function splitOn(
}
}
if(pagesArray.length > 0) {
subDocuments.push(await selectPages(file, pagesArray));
subDocuments.push(await selectPages({file, pagesToExtractArray:pagesArray}));
}
pagesArray = [];