fix(node): preserve sync bake() API by dynamically chaining async operations

This commit is contained in:
engin0223 2026-03-07 15:00:30 +03:00
parent 8402c1cafb
commit b5e8260129

View File

@ -88,14 +88,21 @@ class NodeRecipe {
* @param {NodeDish} dish
* @returns {NodeDish}
*/
async execute(dish) {
let prev = dish;
for (const curr of this.opList) {
if (Object.prototype.hasOwnProperty.call(curr, "op") &&
Object.prototype.hasOwnProperty.call(curr, "args")) {
prev = await curr.op(prev, curr.args);
} else {
prev = await curr(prev);
execute(dish) {
return this.opList.reduce((prev, curr) => {
const runOp = (input) => {
if (Object.prototype.hasOwnProperty.call(curr, "op") &&
Object.prototype.hasOwnProperty.call(curr, "args")) {
return curr.op(input, curr.args);
}
return curr(input);
};
if (prev && typeof prev.then === 'function') {
return prev.then(runOp);
}
}
return prev;