import { assertEquals } from "jsr:@std/assert"
assertEquals(
unpackSeq(
Uint8Array.of(0x00, 0x12, 0xAB, 0x98, 104, 101, 108, 108, 111, 0), // byte buffer
0, // starting index
["u4b"], // first decoded item should be a 4-byte unsigned integer in big-endian byte-order.
["str", 5], // the second item should be a string consisting of 5 bytes (5 characters in this case).
["bool"], // the last item should be a 1-byte boolean.
), [
[0x12AB98, "hello", false], // decoded items
10, // bytes decoded
],
)
decodes as a sequential array of items, provided that you pair the values with their
PrimitiveType
s. this is the inverse of packSeq.under the hood, this function uses unpack for decoding each item.