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:
@@ -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 = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user