Function LittleEndian

  • @LittleEndian decorator set the endianness of a decorated class or property to little endian.

    Type Parameters

    • This

      The type of the class the decorator is applied to.

    Parameters

    • _: any
    • context: ClassAndPropertyDecoratorContext<This>

    Returns void

    Set the endianness of an entire type definition

    Use the @LittleEndian decorator on top of a class declaration to change the endianness of all its properties.

    In the following example, the Protocol type definition that include two unsigned 32bits integer: foo and bar, will use little-endian byte order.

    @LittleEndian
    class Protocol {
    @Uint32
    foo: number

    @Uint32
    bar: number
    }
    • The difference with Endian is that this decorator is not dynamic. The endianness won't be set back to it's previous value after the decorated class/property is read.

    • When working with recursive binary definition be sure to use this decorator instead of Endian.