Function jdpack

  • Format strings are space-separated sequences of type descriptions. All numbers are understood to be little endian. The following type descriptions are supported:

    • u8, u16, u32 - unsigned, 1, 2, and 4 bytes long respectively
    • i8, i16, i32 - similar, but signed
    • b - buffer until the end of input (has to be last)
    • s - similar, but utf-8 encoded string
    • z - NUL-terminated utf-8 string
    • b[10] - 10 byte buffer (10 is just an example, here and below)
    • s[10] - 10 byte utf-8 string; trailing NUL bytes (if any) are removed
    • x[10] - 10 bytes of padding

    There is one more token, r:. The type descriptions following it are repeated in order until the input buffer is exhausted. When unpacking, fields after r: are repeated as an array of tuples.

    In case there's only a single field repeating, it's also possible to append [] to its type, to get an array of values.

    Type Parameters

    Parameters

    • fmt: string
    • data: T

    Returns Uint8Array

Generated using TypeDoc