Function Padding

  • @Padding ensures that the total size of the decorated property aligns to a multiple of the specified padding value. After reading or writing the property, the cursor is advanced forward if necessary to maintain alignment.

    Type Parameters

    • This extends object

    Parameters

    • padding: number

      The total size of the decorated property will be adjusted to be a multiple of this value.

    • Optionalopt: Partial<PrePostOptions>

      Optional configution.

    Returns ClassAndPropertyDecoratorType<This>

    The class or property decorator function.

    In the following example the data property is padded so the length (after read or write) is a multiple of 4.

    class Protocol {
    @Uint32
    length: number

    @Padding(4)
    @Count('length')
    @Uint8
    data: number[]
    }