BarefootJS
view release on metacpan or search on metacpan
lib/BarefootJS/Evaluator.pm view on Meta::CPAN
my $arrow = $args->[0];
return () unless ref $arrow eq 'HASH' && ($arrow->{kind} // '') eq 'arrow';
return ($prop, $callee->{object}, $arrow);
}
# _array_callback($method, $object_node, $arrow_node, $env): evaluate the
# receiver (`$object_node`) against $env, then map/filter it through the
# arrow's body. `params` in the decoded JSON is an array ref of plain
# strings (e.g. `["t"]` or `["t","i"]`) â 1 param binds the element, 2
# params bind (element, index). The child env is a COPY of the parent env
# (never mutated in place across sibling iterations), with the param
# name(s) bound per call â matches Go's per-call `inner` env copy.
sub _array_callback ($method, $object_node, $arrow_node, $env) {
my $arr = evaluate($object_node, $env);
return undef unless ref $arr eq 'ARRAY';
my @params = @{ $arrow_node->{params} // [] };
my $body = $arrow_node->{body};
my $call_cb = sub {
my ($item, $index) = @_;
my %inner = %$env;
$inner{ $params[0] } = $item if @params >= 1;
( run in 1.454 second using v1.01-cache-2.11-cpan-4ab04211f4c )