fix(node): enable asynchronous operation support in Node.js API

This commit is contained in:
engin0223 2026-03-05 17:14:14 +03:00 committed by GCHQDeveloper581
parent cfc84f543c
commit 212a2c68c3
No known key found for this signature in database
GPG Key ID: 6222E059A3DF595C
2 changed files with 11 additions and 10 deletions

View File

@ -88,16 +88,17 @@ class NodeRecipe {
* @param {NodeDish} dish * @param {NodeDish} dish
* @returns {NodeDish} * @returns {NodeDish}
*/ */
execute(dish) { async execute(dish) {
return this.opList.reduce((prev, curr) => { let prev = dish;
// CASE where opList item is op and args for (const curr of this.opList) {
if (Object.prototype.hasOwnProperty.call(curr, "op") && if (Object.prototype.hasOwnProperty.call(curr, "op") &&
Object.prototype.hasOwnProperty.call(curr, "args")) { Object.prototype.hasOwnProperty.call(curr, "args")) {
return curr.op(prev, curr.args); prev = await curr.op(prev, curr.args);
} else {
prev = await curr(prev);
} }
// CASE opList item is just op. }
return curr(prev); return prev;
}, dish);
} }
} }

View File

@ -324,10 +324,10 @@ export function help(input) {
* @returns {NodeDish} of the result * @returns {NodeDish} of the result
* @throws {TypeError} if invalid recipe given. * @throws {TypeError} if invalid recipe given.
*/ */
export function bake(input, recipeConfig) { export async function bake(input, recipeConfig) {
const recipe = new NodeRecipe(recipeConfig); const recipe = new NodeRecipe(recipeConfig);
const dish = ensureIsDish(input); const dish = ensureIsDish(input);
return recipe.execute(dish); return await recipe.execute(dish);
} }