Length-prefixed deframing
Your task
Deframe a byte stream of length-prefixed messages. The input is a list of byte values. Each message is a single length-prefix byte N followed by exactly N payload bytes. Return a list of payloads (each a list of ints) in order. If the stream ends in the middle of a frame (fewer than N payload bytes remain), discard that trailing incomplete frame. A length byte of 0 yields an empty payload.
Examples
deframe(stream: list[int]) -> list[list[int]]Example 1
Input
deframe([3, 1, 2, 3, 2, 9, 8])Output
[[1, 2, 3], [9, 8]]