mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-02-02 00:16:34 +01:00
Typed Operations
This commit is contained in:
parent
89e8c3b0ba
commit
185cd1c0a7
@ -1,5 +1,9 @@
|
||||
export interface Operation {
|
||||
values: {id:any};
|
||||
protected values: any;
|
||||
type: string;
|
||||
operations?: Operation[];
|
||||
}
|
||||
|
||||
export interface WaitOperation extends Operation {
|
||||
values: { id: number }
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { organizeWaitOperations } from "./organizeWaitOperations.js";
|
||||
import { Operation } from "../../declarations/Operation.js";
|
||||
import { Operation, WaitOperation } from "../../declarations/Operation.js";
|
||||
import { PDF } from "../../declarations/PDF.js";
|
||||
|
||||
export async function * traverseOperations(operations: Operation[], input: PDF[] | PDF, Operations: AllOperations) {
|
||||
@ -9,7 +9,7 @@ export async function * traverseOperations(operations: Operation[], input: PDF[]
|
||||
return results;
|
||||
|
||||
async function * nextOperation(operations: Operation[] | undefined, input: PDF[] | PDF) {
|
||||
if(Array.isArray(operations) && operations.length == 0) { // isEmpty
|
||||
if(operations === undefined || (Array.isArray(operations) && operations.length == 0)) { // isEmpty
|
||||
if(Array.isArray(input)) {
|
||||
console.log("operation done: " + input[0].fileName + (input.length > 1 ? "+" : ""));
|
||||
results = results.concat(input);
|
||||
@ -33,7 +33,7 @@ export async function * traverseOperations(operations: Operation[], input: PDF[]
|
||||
case "done": // Skip this, because it is a valid node.
|
||||
break;
|
||||
case "wait":
|
||||
const waitOperation = waitOperations[operation.values.id];
|
||||
const waitOperation = waitOperations[(operation as WaitOperation).values.id];
|
||||
|
||||
if(Array.isArray(input)) {
|
||||
waitOperation.input.concat(input); // TODO: May have unexpected concequences. Needs further testing!
|
||||
|
Loading…
Reference in New Issue
Block a user