found a way to improve yields

fixed list rendering in README.md
This commit is contained in:
Felix Kaspar 2023-10-21 17:27:43 +02:00
parent 2bc618d66b
commit f402a36042
2 changed files with 57 additions and 101 deletions

View File

@ -77,50 +77,50 @@ If you are interested in learning about this, take a look at the Example workflo
### New ### New
[ ] Propper auth using passportjs - [x] Client side PDF-Manipulation
[x] Workflows - [x] Workflows
[ ] Node based editing of them. - [ ] Stateful UI
[x] Client side PDF-Manipulation - [ ] Node based editing of them
[ ] Stateful UI - [ ] Propper auth using passportjs
### Functions ### Functions
Current functions of spdf and their progress in this repo. Current functions of spdf and their progress in this repo.
[x] Merge - [x] Merge
[x] Split - [x] Split
[x] Rotate - [x] Rotate
[x] Multi-Page-Layout - [x] Multi-Page-Layout
[x] Adjust page size/scale - [x] Adjust page size/scale
[ ] Organize - [ ] Organize
[ ] Change Metadata - [ ] Change Metadata
[ ] Add Watermark - [ ] Add Watermark
[ ] Remove Pages - [ ] Remove Pages
[ ] Remove Blank Pages - [ ] Remove Blank Pages
[ ] Detect/Split Scanned photos - [ ] Detect/Split Scanned photos
[ ] Repair - [ ] Repair
[ ] Compress - [ ] Compress
[ ] Flatten - [ ] Flatten
[ ] Compare/Diff - [ ] Compare/Diff
[ ] Sign - [ ] Sign
[ ] Sign with Certificate - [ ] Sign with Certificate
[ ] Add Password - [ ] Add Password
[ ] Remove Password - [ ] Remove Password
[ ] Change Permissions - [ ] Change Permissions
[ ] Image to PDF - [ ] Image to PDF
[ ] Add image - [ ] Add image
[ ] Extract Images - [ ] Extract Images
[ ] PDF to Image - [ ] PDF to Image
[ ] OCR - [ ] OCR
-
[ ] Convert file to PDF - [ ] Convert file to PDF
[ ] PDF to Text/RTF - [ ] PDF to Text/RTF
[ ] PDF to HTML - [ ] PDF to HTML
[ ] PDF to XML - [ ] PDF to XML
## Contribute ## Contribute

View File

@ -8,9 +8,7 @@ import { organizeWaitOperations } from "./public/organizeWaitOperations.js";
export async function * traverseOperations(operations, input) { export async function * traverseOperations(operations, input) {
const waitOperations = organizeWaitOperations(operations); const waitOperations = organizeWaitOperations(operations);
let results = []; let results = [];
for await (const value of nextOperation(operations, input)) { yield* nextOperation(operations, input)
yield value;
}
return results; return results;
// TODO: Pult all nextOperation() in the for await, like for "extract" // TODO: Pult all nextOperation() in the for await, like for "extract"
@ -30,9 +28,7 @@ export async function * traverseOperations(operations, input) {
} }
for (let i = 0; i < operations.length; i++) { for (let i = 0; i < operations.length; i++) {
for await (const value of computeOperation(operations[i], structuredClone(input))) { yield* computeOperation(operations[i], structuredClone(input));
yield value;
}
} }
} }
@ -61,9 +57,7 @@ export async function * traverseOperations(operations, input) {
waitOperation.waitCount--; waitOperation.waitCount--;
if(waitOperation.waitCount == 0) { if(waitOperation.waitCount == 0) {
for await (const value of nextOperation(waitOperation.doneOperation.operations, waitOperation.input)) { yield* nextOperation(waitOperation.doneOperation.operations, waitOperation.input);
yield value;
}
} }
break; break;
case "removeObjects": case "removeObjects":
@ -73,17 +67,13 @@ export async function * traverseOperations(operations, input) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
// TODO: modfiy input // TODO: modfiy input
input[i].fileName += "_removedObjects"; input[i].fileName += "_removedObjects";
for await (const value of nextOperation(operation.operations, input[i])) { yield* nextOperation(operation.operations, input[i]);
yield value;
}
} }
} }
else { else {
// TODO: modfiy input // TODO: modfiy input
input.fileName += "_removedObjects"; input.fileName += "_removedObjects";
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
} }
break; break;
case "extract": case "extract":
@ -91,17 +81,13 @@ export async function * traverseOperations(operations, input) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
input[i].fileName += "_extractedPages"; input[i].fileName += "_extractedPages";
input[i].buffer = await extractPages(input[i].buffer, operation.values["pagesToExtractArray"]); input[i].buffer = await extractPages(input[i].buffer, operation.values["pagesToExtractArray"]);
for await (const value of nextOperation(operation.operations, input[i])) { yield* nextOperation(operation.operations, input[i]);
yield value;
}
} }
} }
else { else {
input.fileName += "_extractedPages"; input.fileName += "_extractedPages";
input.buffer = await extractPages(input.buffer, operation.values["pagesToExtractArray"]); input.buffer = await extractPages(input.buffer, operation.values["pagesToExtractArray"]);
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
} }
break; break;
case "split": case "split":
@ -120,9 +106,7 @@ export async function * traverseOperations(operations, input) {
}) })
} }
for await (const value of nextOperation(operation.operations, splits)) { yield* nextOperation(operation.operations, splits);
yield value;
}
} }
} }
else { else {
@ -138,9 +122,7 @@ export async function * traverseOperations(operations, input) {
}) })
} }
for await (const value of nextOperation(operation.operations, splits)) { yield* nextOperation(operation.operations, splits);
yield value;
}
} }
break; break;
case "fillField": case "fillField":
@ -150,17 +132,13 @@ export async function * traverseOperations(operations, input) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
// TODO: modfiy input // TODO: modfiy input
input[i].fileName += "_filledField"; input[i].fileName += "_filledField";
for await (const value of nextOperation(operation.operations, input[i])) { yield* nextOperation(operation.operations, input[i]);
yield value;
}
} }
} }
else { else {
// TODO: modfiy input // TODO: modfiy input
input.fileName += "_filledField"; input.fileName += "_filledField";
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
} }
break; break;
case "extractImages": case "extractImages":
@ -170,17 +148,13 @@ export async function * traverseOperations(operations, input) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
// TODO: modfiy input // TODO: modfiy input
input[i].fileName += "_extractedImages"; input[i].fileName += "_extractedImages";
for await (const value of nextOperation(operation.operations, input[i])) { yield* nextOperation(operation.operations, input[i]);
yield value;
}
} }
} }
else { else {
// TODO: modfiy input // TODO: modfiy input
input.fileName += "_extractedImages"; input.fileName += "_extractedImages";
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
} }
break; break;
case "merge": case "merge":
@ -196,9 +170,7 @@ export async function * traverseOperations(operations, input) {
// Only one input, no need to merge // Only one input, no need to merge
input.fileName += "_merged"; input.fileName += "_merged";
} }
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
break; break;
case "transform": { case "transform": {
console.warn("Transform not implemented yet.") console.warn("Transform not implemented yet.")
@ -206,17 +178,13 @@ export async function * traverseOperations(operations, input) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
// TODO: modfiy input // TODO: modfiy input
input[i].fileName += "_transformed"; input[i].fileName += "_transformed";
for await (const value of nextOperation(operation.operations, input[i])) { yield* nextOperation(operation.operations, input[i]);
yield value;
}
} }
} }
else { else {
// TODO: modfiy input // TODO: modfiy input
input.fileName += "_transformed"; input.fileName += "_transformed";
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
} }
break; break;
} }
@ -225,17 +193,13 @@ export async function * traverseOperations(operations, input) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
input[i].fileName += "_extractedPages"; input[i].fileName += "_extractedPages";
input[i].buffer = await extractPages(input[i].buffer, operation.values["pagesToExtractArray"]); input[i].buffer = await extractPages(input[i].buffer, operation.values["pagesToExtractArray"]);
for await (const value of nextOperation(operation.operations, input[i])) { yield* nextOperation(operation.operations, input[i]);
yield value;
}
} }
} }
else { else {
input.fileName += "_extractedPages"; input.fileName += "_extractedPages";
input.buffer = await extractPages(input.buffer, operation.values["pagesToExtractArray"]); input.buffer = await extractPages(input.buffer, operation.values["pagesToExtractArray"]);
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
} }
break; break;
case "rotate": case "rotate":
@ -243,17 +207,13 @@ export async function * traverseOperations(operations, input) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
input[i].fileName += "_turned"; input[i].fileName += "_turned";
input[i].buffer = await rotatePages(input[i].buffer, operation.values["rotation"]); input[i].buffer = await rotatePages(input[i].buffer, operation.values["rotation"]);
for await (const value of nextOperation(operation.operations, input[i])) { yield* nextOperation(operation.operations, input[i]);
yield value;
}
} }
} }
else { else {
input.fileName += "_turned"; input.fileName += "_turned";
input.buffer = await rotatePages(input.buffer, operation.values["rotation"]); input.buffer = await rotatePages(input.buffer, operation.values["rotation"]);
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
} }
break; break;
case "impose": case "impose":
@ -261,17 +221,13 @@ export async function * traverseOperations(operations, input) {
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
input[i].fileName += "_imposed"; input[i].fileName += "_imposed";
input[i].buffer = await impose(input[i].buffer, operation.values["nup"], operation.values["format"]); input[i].buffer = await impose(input[i].buffer, operation.values["nup"], operation.values["format"]);
for await (const value of nextOperation(operation.operations, input[i])) { yield* nextOperation(operation.operations, input[i]);
yield value;
}
} }
} }
else { else {
input.fileName += "_imposed"; input.fileName += "_imposed";
input.buffer = await impose(input.buffer, operation.values["nup"], operation.values["format"]); input.buffer = await impose(input.buffer, operation.values["nup"], operation.values["format"]);
for await (const value of nextOperation(operation.operations, input)) { yield* nextOperation(operation.operations, input);
yield value;
}
} }
break; break;
default: default: