src/Text/TextReader.php
public function peek(int $length = 1, float $timeout = 0): \Generator
    {
        // Read chunks of bytes until we reach the desired length.
        while (mb_strlen((string) $this->buffer, $this->encoding) < $length && $this->stream->isReadable()) {
            $this->buffer->push(yield from $this->stream->read(0, null, $timeout));
        }

        return mb_substr((string) $this->buffer, 0, min($length, $this->buffer->getLength()), $this->encoding);
    }
public function peek(int $length = 1, float $timeout = 0): \Generator
    {
        // Read chunks of bytes until we reach the desired length.
        while (mb_strlen((string) $this->buffer, $this->encoding) < $length && $this->stream->isReadable()) {
            $this->buffer->push(yield from $this->stream->read(0, null, $timeout));
        }

        return mb_substr((string) $this->buffer, 0, min($length, $this->buffer->getLength()), $this->encoding);
    }
@coroutine

Returns the next sequence of characters without consuming them.

@param int $length The number of characters to peek.
@param float|int $timeout Number of seconds until the returned promise is rejected with a TimeoutException
if no data is received. Use 0 for no timeout.

@return \Generator

@resolve string String of characters read from the stream.

@throws \Icicle\Awaitable\Exception\TimeoutException If the operation times out.
@throws \Icicle\Stream\Exception\UnreadableException If the stream is no longer readable.
@throws \Icicle\Stream\Exception\ClosedException If the stream is unexpectedly closed.