• @Until decorator reads variable-length array from binary stream until a specified terminating character or magic number is encountered.

    The main difference between @Until and @Count is that @Until supports reading data of an undefined length, terminating when a specific character is met. This makes it useful for reading data that ends with a special character or an EOF symbol.

    Type Parameters

    • This

      The type of the class the decorator is applied to.

    • Value

      The type of the decorated property.

    Parameters

    • cmp: string | number | typeof EOF

      The comparison value that indicates the end of the reading process. This can be a specific character, number, or the EOF symbol.

    • Optionalopt: Partial<ControllerOptions>

      Optional configuration.

    Returns DecoratorType<This, Value>

    The property decorator function.

    You can use this decorator to read relation or primitive until the EOF.

    class BinProtocol {
    @Until(EOF)
    @Relation(PrimitiveSymbol.u8)
    array: number[]
    }

    This decorator does not accept a function as argument. If you need to use a function to verify an equality based on the currently read value use the While decorator instead.