nozavroni / csvelte

🕺🏻 CSV and Tabular Data library for PHP
http://phpcsv.com/
Other
6 stars 0 forks source link

Implement an iterator stream #122

Closed nozavroni closed 7 years ago

nozavroni commented 7 years ago

Implement a stream class that accepts an iterator. Then when a read is requested, cycle the iterator and buffer any unused data.

$stream = new IteratorStream(new SplFileObject($filename));
$stream->read(1000);

Internally...

public function read($length)
{
    $this->iter->next();
    [$data, $remainder] = $this->chop($this->iter->current(), $length);
    $this->buffer = $remainder;
    return $data;
}

Except that it would need ot return stuff from the buffer before calling next and current.

nozavroni commented 7 years ago

AFAIK this is finished... needs documentation. Possibly more unit testing.

nozavroni commented 7 years ago

Closing all issues that only need documentation.