factor out ArrayStream, update new stream types to respect peek
[catagits/HTML-Zoom.git] / lib / HTML / Zoom / FlattenedStream.pm
CommitLineData
8a1c87d1 1package HTML::Zoom::FlattenedStream;
2
3use strict;
4use warnings FATAL => 'all';
5use base qw(HTML::Zoom::StreamBase);
6
7sub new {
8 my ($class, $args) = @_;
9 bless({ _source => $args->{source}, _zconfig => $args->{zconfig} }, $class);
10}
11
b5a48c47 12sub _next {
13
8a1c87d1 14 return unless (my $self = shift)->{_source};
15 my ($next, $s);
16 until (($next) = ($s = $self->{_cur}) ? $s->next : ()) {
17 unless (($self->{_cur}) = $self->{_source}->next) {
18 delete $self->{_source}; return;
19 }
20 }
21 return $next;
22}
23
241;