Closed nozavroni closed 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.
AFAIK this is finished... needs documentation. Possibly more unit testing.
Closing all issues that only need documentation.
Implement a stream class that accepts an iterator. Then when a read is requested, cycle the iterator and buffer any unused data.
Internally...
Except that it would need ot return stuff from the buffer before calling next and current.