1 package HTML::Zoom::MappedStream;
4 use base qw(HTML::Zoom::StreamBase);
7 my ($class, $args) = @_;
9 _source => $args->{source}, _mapper => $args->{mapper},
10 _zconfig => $args->{zconfig}
15 my ($self, $am_peek) = @_;
16 return unless $self->{_source};
17 # If we were aiming for a "true" perl-like map then we should
18 # elegantly handle the case where the map function returns 0 events
19 # and the case where it returns >1 - if you're reading this comment
20 # because you wanted it to do that, now would be the time to fix it :)
21 if (my ($next) = $self->{_source}->${\($am_peek ? 'peek' : 'next')}) {
22 $self->{_peeked_from} = $next if $am_peek;
24 return $self->{_mapper}->($next);
26 delete $self->{_source};