14 lines
388 B
JavaScript
14 lines
388 B
JavaScript
export default function(node, {evaluate, scope}) {
|
|
const test = evaluate(node.test, {scope});
|
|
if (test.async) {
|
|
return {
|
|
async: true,
|
|
value: (
|
|
Promise.resolve(test.value)
|
|
.then((test) => evaluate(test ? node.consequent : node.alternate).value, {scope})
|
|
),
|
|
};
|
|
}
|
|
return evaluate(test.value ? node.consequent : node.alternate, {scope});
|
|
}
|