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