amphp / byte-stream

A non-blocking stream abstraction for PHP based on Amp.

Home Page:https://amphp.org/byte-stream

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LineReader custom delimiter

userqq opened this issue · comments

Hi.
It would be great to have possibility use custom delimiters in LineReader, e.g.

final class LineReader
{
    ...
    public function __construct(InputStream $inputStream, $delimiter = "\n")
    ...
}
$reader = new \Amp\ByteStream\LineReader($stream, "\x0a\x00");

Looks like a useful addition. However, it needs some special consideration for \rtrim($line, "\r"); which shouldn't be applied in that case. Do you want to provide a PR?

@kelunik
Please see draft PR #77