From 4595b5f5f6118c2e52a336055faec498a581e7fd Mon Sep 17 00:00:00 2001 From: engin0223 Date: Sat, 7 Mar 2026 15:15:44 +0300 Subject: [PATCH] fix(node): refactor execute method to use async/await for operation execution --- src/node/NodeRecipe.mjs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/node/NodeRecipe.mjs b/src/node/NodeRecipe.mjs index 1bb24209..28376ba5 100644 --- a/src/node/NodeRecipe.mjs +++ b/src/node/NodeRecipe.mjs @@ -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; + })(); } }