2024-06-22 10:47:17 -05:00
|
|
|
export default function(node, {evaluate, scope}) {
|
|
|
|
const {computed, object, property, wrapper} = node;
|
2024-06-16 08:01:01 -05:00
|
|
|
const member = (O, P) => (wrapper?.optional ? O?.[P] : O[P]);
|
|
|
|
const O = evaluate(object, {scope});
|
2024-06-22 10:47:17 -05:00
|
|
|
const P = computed
|
|
|
|
? evaluate(property, {scope})
|
|
|
|
// Otherwise, identifier
|
|
|
|
: {value: property.name};
|
2024-06-16 08:01:01 -05:00
|
|
|
if (O.async || P.async) {
|
|
|
|
return {
|
|
|
|
async: true,
|
|
|
|
value: Promise.all([O.value, P.value]).then(([O, P]) => member(O, P)),
|
|
|
|
};
|
|
|
|
}
|
2024-06-30 10:03:50 -05:00
|
|
|
return {async: false, value: member(O.value, P.value)};
|
2024-06-16 08:01:01 -05:00
|
|
|
}
|