struct (js, cli)
struct packs primitive values into bytes and back. Declare it with edge add struct and import it by bare name. To pin a different version, point the edge.json entry at another URL, see Modules.
Functions are pack(fmt, *values), unpack(fmt, data), and calcsize(fmt). Codes are x b B ? h H i I q Q f d with repeat counts, and byte-order prefixes are < (the default), =, >, !. There is no native-alignment mode. unpack returns a list. A packed buffer crosses the host boundary once, which makes it the fast lane for bulk numeric data. Out-of-range integers raise ValueError, non-integer values for integer codes raise TypeError, and f / d accept integers. Not implemented: s / p strings, e half floats, n / N, and pack_into / unpack_from / iter_unpack.
[92.5, -115.25, 0.75] 4
The byte-order prefix picks the layout:
b'\x02\x01' b'\x01\x02' [70000]
A value that does not fit its code raises ValueError:
out of range: argument out of range for 'B'