How a Channel behaves when its consumer cannot keep up.
const options: ChannelOptions<number> = { capacity: 1_000, overflow: 'dropNewest' }; options.capacity; // 1000 — past this, `overflow` decides which element is lost
optional
capacity: number
How many elements to buffer for a consumer that has not taken them yet. Default 10_000.
What to do once capacity is reached: drop from either end, or 'fail' — end the stream
with a ChannelOverflowFailure element instead of losing anything quietly.
Default 'dropOldest'.
Called with each element the buffer actually lost, and the depth after the loss. The only
place overflow is observable — make it fatal from here by calling fail or abort.
optional
onDemand: () => void
Called once, when a consumer first attaches. A producer that can defer starting should start here: it is the difference between a buffer that stays near empty and one that races ahead of a consumer that has not arrived.