def read_nbytes(buffer: bytearray, length: int) -> bytes:
    """ Read the given number of bytes, read bytes are consumed.
    """
    array = bytes(buffer[:length])
    del buffer[:length]
    return array