silphius/app/astride/evaluators/array.js
2024-06-22 10:47:17 -05:00

14 lines
350 B
JavaScript

export default function(node, {evaluate, scope}) {
const elements = [];
let isAsync = false;
for (const element of node.elements) {
const {async, value} = evaluate(element, {scope});
isAsync = isAsync || async;
elements.push(value);
}
return {
async: !!isAsync,
value: isAsync ? Promise.all(elements) : elements,
};
}