BodyReader
Defined in: packages/format-core/src/body-reader.ts:28
Turns a declared BodySpec into a ReadableStream, fed byte-by-byte
(or chunk-by-chunk) as they arrive alongside or after a decoded value.
Extracted from net/core’s Framer (now FrameLink) so the same
deferred-materialization mechanics — an opaque payload declared by a decoder
and streamed rather than buffered — are available to any consumer, not just a
live transport. First consumer: FrameLink; a RIFF/WAV reader or an IMAP
literal retrofit are the next two, per format-interface-dimensions.md.
Cancelling stream does not stop the body: its remaining bytes are still consumed by feed, and dropped, so whatever follows the body on the same carrier stays in sync.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BodyReader(
spec,options):BodyReader
Defined in: packages/format-core/src/body-reader.ts:38
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”BodyReader
Properties
Section titled “Properties”stream
Section titled “stream”
readonlystream:ReadableStream<Uint8Array<ArrayBufferLike>>
Defined in: packages/format-core/src/body-reader.ts:36
The stream to hand to whoever is consuming the body.
Accessors
Section titled “Accessors”finished
Section titled “finished”Get Signature
Section titled “Get Signature”get finished():
boolean
Defined in: packages/format-core/src/body-reader.ts:65
Whether every byte of the body has been fed, or the body was discarded.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”discard()
Section titled “discard()”discard(
error?):void
Defined in: packages/format-core/src/body-reader.ts:128
Errors the stream, for a transport failure or a mode switch mid-body. Idempotent: a second call is a no-op.
Leaves backpressure as it is: whoever discards decides what happens to the carrier next.
Parameters
Section titled “Parameters”error?
Section titled “error?”unknown
Returns
Section titled “Returns”void
feed()
Section titled “feed()”feed(
chunk):number
Defined in: packages/format-core/src/body-reader.ts:74
Push up to remaining bytes of chunk into the stream.
Parameters
Section titled “Parameters”Uint8Array
Returns
Section titled “Returns”number
How many bytes of chunk were consumed by the body.
finish()
Section titled “finish()”finish():
void
Defined in: packages/format-core/src/body-reader.ts:110
Closes the stream normally. Idempotent: a second call is a no-op.
Lifts any backpressure this reader applied: the bytes after the body are no longer its to hold back, and a closed stream is never pulled again.
Returns
Section titled “Returns”void
finishAtEof()
Section titled “finishAtEof()”finishAtEof():
void
Defined in: packages/format-core/src/body-reader.ts:98
Signals end-of-input for an until-eof body; a no-op for a length one.
Returns
Section titled “Returns”void