API reference / @jsprismarine/script-host / debugger/framing / FrameDecoder
Class: FrameDecoder
Defined in: script-host/src/debugger/framing.ts:44
Splits the bytes of a connection into messages, whatever sizes the chunks arrive in. The extension reads each body as JSON whole, so a body's trailing newline is part of the JSON's whitespace and the decoder does not require it. Chunks wait in a list until a header or a body is complete, so each byte is copied at most once more however small the chunks are.
Constructors
Constructor
new FrameDecoder():
FrameDecoder
Returns
FrameDecoder
Methods
push()
push(
chunk):unknown[]
Defined in: script-host/src/debugger/framing.ts:55
Takes the next chunk of bytes.
Parameters
chunk
Uint8Array
Returns
unknown[]
The messages the bytes so far complete, in order.
Throws
When a header is not 8 hexadecimal digits and a newline, a header states a body longer than MAX_RECEIVED_FRAME_LENGTH, or a body is not JSON.