fix(node): refactor execute method to use async/await for operation execution

This commit is contained in:
engin0223 2026-03-07 15:15:44 +03:00
parent c4f4735626
commit 4595b5f5f6

View File

@ -89,24 +89,21 @@ class NodeRecipe {
* @returns {NodeDish}
*/
execute(dish) {
return this.opList.reduce((prev, curr) => {
return (async () => {
let currentInput = dish;
const runOp = (input) => {
for (const curr of this.opList) {
// Check if it's an operation object or a direct function
if (Object.prototype.hasOwnProperty.call(curr, "op") &&
Object.prototype.hasOwnProperty.call(curr, "args")) {
return curr.op(input, curr.args);
currentInput = await curr.op(currentInput, curr.args);
} else {
currentInput = await curr(currentInput);
}
}
return curr(input);
};
if (prev && typeof prev.then === "function") {
return prev.then(runOp);
}
return runOp(prev);
}, dish);
return currentInput;
})();
}
}