def bin_string_to_bytearray(binary_string: str) -> bytearray:
    """Converts a binary string to a bytearray

    Parameters
    ----------
    binary_string: str
       The binary string used to build the bytearray

    Returns
    -------
    bytearray
       The generated bytearray
    """

    # Fill in bits if the binary string is not dividable by 8 (byte)
    binary_string += ((8 - len(binary_string)) % 8) * '0'

    # Generate the bytearray
    bytes_array = bytearray()
    for binary_byte in [binary_string[i:i + 8] for i in range(0, len(binary_string), 8)]:
        bytes_array.append(int(binary_byte, 2))

    return bytes_array